Do I have to create an index on the _id parameter?
Do I have to do this or is this automatically done by Convex?
I want to find a value in my 200.000 document long db by id and I think to do this fast I need an index.
3 Replies
no need to create index on _id you can directly use
db.get(pass the id)
Hi, thank you Abhishek, that worked.
Now I need to parse the string on the frontend to ensure that is it an id:
TS2345: Argument of type "skip" | { id: string; } is not assignable to parameter of type { id: Id<"search">; } | "skip"
How can I do that?
You can cast it
query.cityId as Id<"search">
or you can pass it up as a v.string()
and make sure it's an id in the query with const cityId = ctx.db.normalizeId("search", args.id)