PrismaP
Prisma2y ago
1 reply
Mert Efe

Why getting typescript error only selecting few fields?

 const admins = await this.prisma.admin.findMany({
      where: {
        ...filters,
      },
      select: {
        id: true,
        email: true,
        userName: true,
        deleted: true,
      },
    });

    return admins;


src/admin/admin.service.ts:56:5 - error TS2322: Type '{ id: number; email: string; userName: string; deleted: boolean; }[]' is not assignable to type '{ id: number; email: string; userName: string; password: string; role: AdminRole; deleted: boolean; createdAt: Date; }[]'.
  Type '{ id: number; email: string; userName: string; deleted: boolean; }' is missing the following properties from type '{ id: number; email: string; userName: string; password: string; role: AdminRole; deleted: boolean; createdAt: Date; }': password, role, createdAt

56     return admins;
       ~~~~~~

[1:25:46 PM] Found 1 error. Watching for file changes.
Was this page helpful?