Im a newbie creating a document editor and idk how to setup an architecture to save the data

I'm using tip tap for the editor on the front end while using Postgresql with bun on the back end. I have an idea of how I could do it, but it seems not that effective, I would like your suggestions for another solution. I am thinking of saving the document content in a JSON format, as tip tap allows you, and saving it into a Postgresql row. The problem is that every time you update the document, you are sending the whole document content in a request, which would make each request to be very heavy, even if you just updated a single character. This would consume a lot of bandwidth for both the user and the server.
No description
G
Gad17d ago
honestly, it should be fine imo unless there are embedded fonts or images, it isnt really that much data
H
Huilen16d ago
isnt it?
M
Max16d ago
Yeah just save it as json. if you're using prisma you can set it as a field in a table as Json. and if using prisma use a transact to make sure your delete and create prisma queries work. If it deletes and create fails it will role back and throw an error.
M
Mocha16d ago
What's your main concern here? Cost of bandwidth? Time to update? Cost of storage? * If it's the cost of bandwidth, and this is a new project, then I'd say this is premature optimization, which I get it, I'm guilty of this habit too : ) * If you're worried about the server handling too much, then you're fine. The server won't do much with it more than copying it. * Storage is cheap, so no worries, at least for now. * Time, the user doesn't need to await a result * Also, you're probably already doing this, but consider adding some sort of delay. One character maybe isn't worth sending a whole request, so you can wait till either the user types 3 chars or 3 seconds pass.
H
Huilen15d ago
thank you its ttrue maybe i can call editor.getText() and compare the strings and count the differences and i can make use of delays too I was just worried that I was going to choose this approach over the more complex one of detecting each transaction on the editor and sending it to the backend to in some way be able to manipulate the JSON but I was worried unnecessarily
M
Mocha15d ago
Yes, especially if this is a personal project, please ignore that and just try to ship something functional as soon as you can. Nothing else matters before production. You can always optimize later, when you know more about what you wanna do!
H
Huilen14d ago
right
Want results from more Discord servers?
Add your server
More Posts
Differences Between ProvidersI'm in a small team and we are looking for some cloud providers to have the following things: - Servhow to use yarnrc.ymlI found this ``` nodeLinker: node-modules plugins: - path: .yarn/plugins/@yarnpkg/plugin-workspacA guide for tRPC MySQL drizzle testing setupHey folks I have built a product using t3 stack with MySQL db and drizzle as the ORM. I would like tshadcn/ui: Why do I get the incorrect error message?If I don't type anything in I only get the "required" message despite defining a message in the zod TRPCClientError: Unable to transform response from serverI just migrated from Next Auth to Clerk. Clerk is working fine. tRPC works fine too, but I keep gettBasic system design questions for a big projectHey, I am making a fairly ambitious app and wanted some advice on how to proceed with my system desiValidation error in JSON schema provided by user against the JSON Schema draft 2020-12?I have integrated monaco editor on my website and I want users to input JSON data and validate it agHow to change refType in forwardRef based on prop?imagine you want a React component to have a certain ref type if some prop is present, and another rHow do I migrate from Next-Auth to Clerk Auth?I recently started a project with with all options enabled with create T3 stack command, how do I miState ManagementI need help in managing state in nextjs, can someone help metable schema admins tableIs it better to have a table for admins a table for moderators and a tabble for users, or have just Prisma w/pgvectorHey, we got this t3 app, but Prisma does not support vectors when trying to query the column that's keep previous datathe latest t3 app doesn't support keepPreviousData in useQuery? App router, drizzlem, trpc setup.t3-env setup with tsxHi, I wanted to have a script `pnpm db:migrate` to run the drizzle migrations to the database. This Generic EventEmitter ClassI am trying to make the eventEmitter class generic, however many type errors occur such as: > Propeaxios + multipart/formdatapardon my stupidity, i'm coming from python :P how do i specify `Content-Type` and `filename` in AxUnhelpful useQuery errorI'm trying to either get an id from stored cookies or if not found, query for fresh id using trpc, twhy 401 status code doesn't trigger `response.ok` to be false?hi, i think this is a misunderstanding of the fetch API. Is response.ok a boolean to validate if theMaybe i am dumb, but how can i detect if dynamically component has loaded or loading.js have closed?Can not figure it out. By loading.js i mean loading.tsx in app folder.typescript globals: @types/web overrides fetchHey all I have a pnpm monorepo with a couple of packages and two next apps. In the next apps 'window