50BytesOfJohn
Explore posts from serverswhat is the ideal column type to store the content of a Tiptap editor?
@AD Amorim not sure about the performance of such approach but in case of bigger documents maybe you could store it as files in some storage like AWS S3, or maybe even xata file storage and just keep the reference to the file in database.
10 replies
what is the ideal column type to store the content of a Tiptap editor?
Hey, I'm actually using xata and tiptap in one project. I was also wondering about the approach and reading about this for a while, as it's kinda not obvious and it also depends on use case and what features do you need. I'm using basic editor stuff, like simple formatting and code blocks. After user edits etc. I'm sending html, and processing it with rehype pipeline, some sanitization, code highlighting etc. and then saving the produced html to text column. When the user wants to edit document, i'm loading this html to tiptap. For now I haven't seen any issues, tiptap understands the formatted html without issues, performance is okey and everything is cool.
I belive that the problem may be when you need to start using some very specific or complicated stuff, like some custom nodes, comments, collaboration. Then I think it's better to keep both HTML and JSON, where html can be used to speed up the rendering (no need to always convert JSON to HTML), and JSON can be used when user want's to edit the document. I found this approach to be used by many people while researching this topic.
When it comes to the column type for JSON, I'm not so experienced, but if you won't be filtering db by the fields from that JSON, I think you can use text column for stringified JSON as well. Some better postgres expert can say if there's any difference :D. Also, as @Oreki mentioned, keep in mind field limits if a document is huge.
10 replies