I am getting an error when trying to delete data t...
# orm-help
g
I am getting an error when trying to delete data that doesn’t exist on db. Is it possible to tell prisma to not throw an error if the requested data doesn’t not exist? I am using mongoDB and
delete
method.
Copy code
await this.prismaService.task.delete({ where: { name } });
name
field is unique
o
There's a an option that can be set in the Prisma client for findUnique/findFirst:
Copy code
/**
     * Configure findUnique/findFirst to throw an error if the query returns null. 
     *  * @example
     *
* // Reject on both findUnique/findFirst * rejectOnNotFound: true * // Reject only on findFirst with a custom error * rejectOnNotFound: { findFirst: (err) => new Error("Custom Error")} * // Reject on user.findUnique with a custom error * rejectOnNotFound: { findUnique: {User: (err) => new Error("User not found")}} *
Copy code
*/
    rejectOnNotFound?: RejectOnNotFound | RejectPerOperation
I thought it could work for your case, but the code doesn't show that. So maybe you have to create a feature request on Github.
n
Hey 👋 I don’t think it’s possible, could you create a Feature Request for it?