Delete
Delete a single record
The following query uses delete
to delete a single User record:
js
const deleteUser = await app.service('User').delete({
where: {
email: 'bert@prisma.io',
},
})
Attempting to delete a user with one or more posts result in an error, as every Post requires an author - see cascading deletes.
Delete multiple records
The following query uses deleteMany
to delete all User records where email contains prisma.io:
js
const deleteUsers = await app.service('User').deleteMany({
where: {
email: {
contains: 'prisma.io',
},
},
})
Attempting to delete a user with one or more posts result in an error, as every Post requires an author - see cascading deletes.
Delete all records
The following query uses deleteMany
to delete all User records:
js
const deleteUsers = await app.service('User').deleteMany({})
Be aware that this query will fail if the user has any related records (such as posts). In this case, you need to delete the related records first.