PrismaP
Prisma7mo ago
6 replies
Dhcdec

Incorrect type being returned from getQueryMethod

type ModelName = Prisma.ModelName;
type ModelDelegate<N extends ModelName> = PrismaClient[Uncapitalize<N>];

export function getQueryMethod<T extends ModelDelegate<ModelName>>(model: T, single: boolean = false) {
  const method = single ? 'findFirst' : 'findMany';
  return model[method];
}

export class ClusterRepository implements IClusterRepository {
  constructor(private readonly databaseClientService: IDatabaseClientService) {}
  

  async getClustersByCriteria(criteria: Prisma.ClusterWhereInput, options: QueryOptions) {
    return withDatabaseError(async () => {
      const refinedClient = getQueryMethod(this.databaseClientService.cluster, options.single);
      return refinedClient({ where: criteria, ...options });
    });
  }

refinedClient is giving me this: 'This expression is not callable.
Each member of the union type '(<T extends AgentFindFirstArgs>(args?: SelectSubset<T, AgentFindFirstArgs<DefaultArgs>> | undefined) => Prisma__AgentClient<GetFindResult<$AgentPayload<DefaultArgs>, T, PrismaClientOptions> | null, null, DefaultArgs, PrismaClientOptions>) | ... 76 more ... | (<T extends UserFindManyArgs>(args?: SelectSubset<...> | u...' has signatures, but none of those signatures are compatible with each other.ts(2349)'
Was this page helpful?