keystone icon indicating copy to clipboard operation
keystone copied to clipboard

`getPrismaModelForList` / `runWithPrisma` functions is not importable in recent Keystone versions

Open MurzNN opened this issue 2 years ago • 1 comments

Sometimes we need to run some direct prisma queries on Lists, having a Keystone's List name. But because of this prisma issue we can't easily do this.

So, in younger versions of Keystone-6 there was a function getPrismaModelForList, but in recent versions it is reworked to runWithPrisma.

And the problem is that it is not exported to compiled version Keystone, so we can't import it into Keystone-based projects to reuse.

Can you please make the function runWithPrisma() importable, or provide any other solution to get Prisma Model from Keystone List name?

Alternative solution can be adding function to Keystone DB API (or Query API?), something like context.db.User.getPrismaClient()

MurzNN avatar Jan 25 '22 19:01 MurzNN

Workaround is to create in each project a custom ugly function like this:

export function listNameToPrismaModel(listKey: string) {
  return listKey.toLowerCase() + listKey.slice(1);
}

But much better to import a same ugly function from Keystone Core ;-P

MurzNN avatar Jan 25 '22 20:01 MurzNN

@MurzNN if you still need this, could you open a feature request GitHub discussion?

dcousens avatar Nov 14 '23 01:11 dcousens