How to delete documents from MongoDB in chunks using gorm?
findAll
followed by delete will not work because of the huge number of documents returned by findAll. It results in heap issue.
I was hoping to send a native mongo db command using Domain class. I do not want to fetch all the domain objects into JVM heap and then iterate to delete them. Instead I want to send the criteria of the deletion to mongo, and let it handle the deletion.
Any pointers on the batch deletion using low level queries? or any other means?
Use the mongo-gorm/gmongo's low-level
API:
SomeDomain.collection.remove( [ date:[ $lt:now ] ] )
see user guide for details