DCsanD
Convex Community3y ago
5 replies
DCsan

helper queries?

I find myself writing a lot of boilerplate helper queries for every class like this.
are there any higher level methods for doing this?
eg I don't know the internal _id but i have my own IDs for tracking relations across tables.

I would like to have my own baseClass for the data tables and just extend to add these common repetitive methods but not sure where/if I can do that.
convex is nice that it's all JS, but it doesn't have the convenience of an actual ORM

async function getCardById(db: any, id: string) {
  const baseCard = await db
    .query("baseCards")
    .filter((bc: any) => bc.eq(bc.field("id"), id))
    .first();
  return baseCard;
}
Was this page helpful?