0

Please help, been stuck for hours, how do I delete a document that matches a query directly in pymodm.

For example:

user = User.objects.raw({'name':'Moses'})

How do I delete this user from my database collection?

panam-py
  • 1
  • 2
  • Have you tried [delete()](https://pymodm.readthedocs.io/en/latest/api/#pymodm.MongoModel.delete)? – Joe Jan 02 '22 at 05:22
  • It's in a queryset so it doesn't work, but i found a workaround so i'm good. Thanks though – panam-py Jan 02 '22 at 11:13

1 Answers1

0

you can use the delete() method to delete document from the MongoDB, try the below code this worked for me fine.

user = User.objects.raw({'name':'Moses'})
user.delete()
mbuechmann
  • 5,413
  • 5
  • 27
  • 40