#Underscores not allowed at start of nested fields

5 messages · Page 1 of 1 (latest)

rotund lion
#

We've run into this issue when storing some data inside v.any() fields. This is a blocker for us cause we have to store changes of our customer's schema in Convex so it would be great to have this limit removed.

If I'm missing something please let me know!

meager adder
#

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.

We’d love for you to have unlimited joy building on Convex but engineering

rotund lion
#

wait here it says field names can start with an underscore?

wet tide
# rotund lion 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.

rotund lion
#

right, JSON.stringify is probably the best in this case