#helper queries?

5 messages · Page 1 of 1 (latest)

mighty estuary
#

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;
}
sand sierra
#

We haven't suggested an ORM to fit on top of our database but you can very much imagine one. I could see something on a replacement db object, which could be supplied by a helper or by middleware.

#

For

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.
check out _generated/dataModel.d.ts which has the types useful for get started on helpers.

#

I'd love to hear if there are ORMs you've especially liked. While there'd be some legwork, adapting existing ORMs or ORM patterns to Convex is absolutely worth thinking about.