{where:{name: undefined}} does prisma delete undef...
# orm-help
g
{where{name undefined}} does prisma delete undefined properties inside where clause??
r
@Gelo 👋
undefined
in this case doesn’t mean undefined properties. It means that you have not passed any value to
where
. In this case, this query will be the equivalent of:
Copy code
prisma.model.deleteMany({ where: {} })
Both of the above queries are equivalent so it will delete all the values present in the database.
In this case, you need to check explicitly if the
name
is defined and only delete those. If you want to delete those records whose name is
null
then you need to use
null
instead like this:
Copy code
prisma.model.deleteMany({
  where: { name: null } 
})
g
Thanks!
👍 1