kunwar.eth
kunwar.eth
PPrisma
Created by kunwar.eth on 5/24/2024 in #help-and-questions
How to filter if a variable is not in database
Hi, I am fetching users like:
const users = await prisma.users.findMany({
where: {
accountStatus: status as accountStatus,
},
select: {
id: true,
email: true,
name: true,
phoneNumber: true,
didCreated: true,
category: true,
accountStatus: true,
did: true,
createdAt: true,
updatedAt: true,
},
});
const users = await prisma.users.findMany({
where: {
accountStatus: status as accountStatus,
},
select: {
id: true,
email: true,
name: true,
phoneNumber: true,
didCreated: true,
category: true,
accountStatus: true,
did: true,
createdAt: true,
updatedAt: true,
},
});
Now if i dont have a category feild in db in on of user i am getting error:
at async orgList (file:///home/shubham/C3i/cemilec-backend/veramo-agent/src/Controllers/Get/UserGetController.ts:49:23) {
code: 'P2032',
clientVersion: '5.14.0',
meta: {
modelName: 'users',
field: 'category',
expected_type: 'String',
found: 'null'
}
}
at async orgList (file:///home/shubham/C3i/cemilec-backend/veramo-agent/src/Controllers/Get/UserGetController.ts:49:23) {
code: 'P2032',
clientVersion: '5.14.0',
meta: {
modelName: 'users',
field: 'category',
expected_type: 'String',
found: 'null'
}
}
Instead what i want is to leave that category for that user and send remaining data
6 replies