Push id of a newly created document to another on creation
My schema looks like this:
My
createColumn mutation:
The Zod schema looks like this:
I would like to push the id of the new column to the respective board document. How can I do this?4 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!
Your mutation doesn't seem to align with your schema (inserting without the board
id field, and tasks isn't in the schema), so I may be missing something. But the basic answer is you'd patch the board right where your // WIP comment is using ctx.db.patch.
That said, you're likely better off just keeping the board id on the columns (I'd call it boardId instead of just id), and then querying all columns for a given board id when you need them. Generally no need to store the column ids on the board unless you have a really particular use case.If you haven't already, I'd highly recommend trying out the tutorial, it walks through a lot of these concepts: https://docs.convex.dev/tutorial/
Convex Tutorial: A Chat App | Convex Developer Hub
Convex provides you with a fully featured backend with cloud functions,
That makes a lot of sense, thanks a lot for the valuable advice! I will be doing that.