Hi guys, not sure if I should ask this on the gene...
# orm-help
o
Hi guys, not sure if I should ask this on the general channel but I’ll give it a try since it seems like a lot of people are asking questions here I’m trying to dynamically call Prisma client by using a readonly array of models, but the client complains that the models don’t have compatible signature calls. Every value in the array is a model name, and all of the models have the same fields, but either way I’m just querying using a where clause on fields both models have
Copy code
const types = [
  'model1',
  'model2',
] as const;


return client[field].findMany({
  where: {
    verified: true,
  },
});
The code works but TypeScript doesn’t like it
Copy code
error TS2349: This expression is not callable.
  Each member of the union type '(<T extends SkillTagFindManyArgs>(args?: SelectSubset<T, SkillTagFindManyArgs>) => CheckSelect<T, PrismaPromise<SkillTag[]>, PrismaPromise<...>>) | ... 4 more ... | (<T extends InterestFindManyArgs>(args?: SelectSubset<...>) => CheckSelect<...>)' has signatures, but none of those signatures are compatible with each other.
Any ideas? Thank you
1
a
Hey Ovidiu 👋🏾 That’s a great question. It’s currently not possible to call Prisma Client dynamically. However, you can add
// @ts-ignore
before the return statement to eliminate the error.