Import mock data including _id
I’m attempting to populate my convex db with mock data and that will have to include the _id fields so that I can create the relationships between documents.
I can see that _ids are base 32 strings (mixture of lower case letters and numbers) but sticking to that format still results in the import telling me “invalid _id”.
How can I generate my own valid ids?
Many thanks!
3 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!
Convex document IDs are not just strings. They're encoded to contain important data that helps Convex validate their use, and the team hasn't yet exposed a way to properly create them outside of the context of inserting a document into a table.
You can create mock data in your dev deployment by writing a mutation function to add some documents, and then run that function either from your in-progress app, or directly from the Convex dashboard. That will create documents with valid IDs that can be used elsewhere.
Thank you for your help, that’s useful to know. I’ll stop chasing the IDs and get the data in by another route.