How to model "custom fields" in Convex?
I want to allow the user to define a set of custom fields similar to Asana or Notion Databases. What is the best way to do that in Convex?
5 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
I would have one table that holds schemas (either a static set you define, or something like a serialized schema), and then in the user tables, have something like
or
Can I index those? Can I filter/soft by user fields? @Ian
You can index on a nested document: https://docs.convex.dev/database/reading-data/indexes/#defining-indexes
Helpful info on filtering nested docs here: https://discord.com/channels/1019350475847499849/1019350478817079338/1282717072203321364
i've been doing this if that helps
The customFields.schema attribute is a JSON Schema (less control but serializable).