#Underscores not allowed at start of nested fields
5 messages · Page 1 of 1 (latest)
It's in the doc under limits, https://docs.convex.dev/production/state/limits its for system fields. I've seen it in multiple sample projects where they almost always serialize the objects removing the underscore. If you want to store a nested _id its generally suggested you create your own id anyway. Or at least rename it. Because you cant insert the original _id back in anyway.
wait here it says field names can start with an underscore?
That's a mistake. The section above it says that you can't, and you actually just can't as you have noticed. It's there to reserve the space for their own future system fields.
I get that you're working pretty directly with your customer's javascript data so it would feel natural to do this, but you're letting external user JSON directly define your database's shape. Remember that you can index directly on these nested keys.
If you are really committed to doing this for some reason, you need to take control of the object's keys, and define your own fields.
But it's actually less work to it the right way and just JSON.stringify.
right, JSON.stringify is probably the best in this case