Crawl
Crawl
PPrisma
Created by Crawl on 9/28/2024 in #help-and-questions
.update return null when data is found using .findUnique using the same where clause (version 5.17.
How is this even possible ? my updatedUser is null, and no updated has been performed But the data exist since the user is found successfully no error is thrown by prisma just updatedUser being null with console loggin User not found or update failed transactionId
const userFound = await this.db.users.findUnique({
where: {
something: xxx,
userId,
},
});

if (!userFound) {
this.logger.log(
`userFound not found`,
);
return null;
}

this.logger.debug('User found');

const updatedUser = await this.db.users.update({
where: {
something: xxx,
userId,
},
data: {
name,
alias,
},
});

if (!updatedUser) {
this.logger.log(
`User not found or update failed transactionId`,
);
return null;
}
const userFound = await this.db.users.findUnique({
where: {
something: xxx,
userId,
},
});

if (!userFound) {
this.logger.log(
`userFound not found`,
);
return null;
}

this.logger.debug('User found');

const updatedUser = await this.db.users.update({
where: {
something: xxx,
userId,
},
data: {
name,
alias,
},
});

if (!updatedUser) {
this.logger.log(
`User not found or update failed transactionId`,
);
return null;
}
6 replies