Patolord
Patolord4w ago

How can I properly store Tiptap's deeply nested JSON editor content in a table?

I have rich text editor that outputs json formated data, the more formating the crazier the json. Should i keep doing this? Im getting warning of deep nesting at level 16
{
content: [
{
content: [
{
marks: [
{
attrs: { color: "rgb(0, 0, 0)" },
type: "textStyle",
},
],
text: "actual random text (this can get really crazy",
type: "text",
},
],
type: "paragraph",
},
],
type: "doc",
}

{
content: [
{
content: [
{
marks: [
{
attrs: { color: "rgb(0, 0, 0)" },
type: "textStyle",
},
],
text: "actual random text (this can get really crazy",
type: "text",
},
],
type: "paragraph",
},
],
type: "doc",
}

No description
11 Replies
erquhart
erquhart4w ago
Is it too big to stringify? The nesting probably isn't meaningful from a database perspective.
Patolord
PatolordOP4w ago
i asked gpt and it said if i stringified it would hurt query time, and indexing
erquhart
erquhart4w ago
I would try it, gpt don't know 'bout us lol
Patolord
PatolordOP4w ago
ok i will try it. it would remove the nesting problem correct
erquhart
erquhart4w ago
I don't know for sure, but I imagine storing complex structured data has it's own penalty.
Patolord
PatolordOP4w ago
its not a problem keeping it nested for me, as it is a internal tool i can just ask people to not go crazy on the rich text editor i was wondering how google docs does it since you can format as much as you would like
erquhart
erquhart4w ago
Convex's prosemirror component (which uses tiptap) uses strings: https://github.com/get-convex/prosemirror-sync/blob/main/src/component/schema.ts
GitHub
prosemirror-sync/src/component/schema.ts at main · get-convex/pros...
Sync prosemirror documents with Convex for server-authorized collaborative editing - get-convex/prosemirror-sync
erquhart
erquhart4w ago
Stringifying json is surprisingly fast in my experience, even in the browser. It's also going to be sent to your function as a string anyway, might as well keep it that way. I'd stringify it right in the browser personally.
Patolord
PatolordOP4w ago
ok i will definitely try stringing it. only thing i lose is if i need to search inside it correct?
erquhart
erquhart4w ago
Yeah you wouldn't be able to do any object level operations on the data at rest, but I'd be surprised if that was actually happening anyway
Patolord
PatolordOP4w ago
great i will do that, thank you very much for the help erquahart!

Did you find this page helpful?