5 Replies
the most common way is to call
const id = await db.insert("whatever", {fields});
which would have type Id<"whatever">
This is on the client side, with the id coming from the url. I'm wanting to pass that into a useQuery call
So I have a string atm, but I want the id type
makes sense. in that case i would cast it
mystr as Id<"whatever">
. https://discord.com/channels/1019350475847499849/1122933700099833984/1130980984641310741Ok, cool, will give that a go thanks
Another option would be to keep the type as
string
and have your convex function call db.normalizeId
to confirm it's actually an ID in the expected table and return the normalized ID in the query (since users could visit invalid URLs like my-app.com/fakeId
).