DylanDev
DylanDev3mo ago

How to find a table entry from _id

I want to query the my table and find the table document that has the _id i pass in. How do I do this?
5 Replies
Convex Bot
Convex Bot3mo ago
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!
DylanDev
DylanDevOP3mo ago
Something like this:
const level = await ctx.db.query("levels").collect(entryId);
^ THIS IS THE ID VARIABLE THAT I HAVE THAT COORISPONDS WITH A _Id IN A TABLE DOCUMENT
const level = await ctx.db.query("levels").collect(entryId);
^ THIS IS THE ID VARIABLE THAT I HAVE THAT COORISPONDS WITH A _Id IN A TABLE DOCUMENT
Clever Tagline
Clever Tagline3mo ago
The second example below this bookmark has what you need: https://docs.convex.dev/functions/query-functions#query-context
Queries | Convex Developer Hub
Queries are the bread and butter of your backend API. They fetch data from the
DylanDev
DylanDevOP3mo ago
@Clever Tagline thank you! i'll @ you if i have any questions
DylanDev
DylanDevOP3mo ago
I'm having an issue now where my backend and my front end are not syncing with my api functions. The client is saying the ids are undefined even tho the server is saying they are being returned. https://gist.github.com/DylanDevelops/c200090842b559c1837591662b1c8154
Gist
GameContext.tsx
GitHub Gist: instantly share code, notes, and snippets.
No description
No description