2

Are there any other alternates in Java to achieve the same in single query in aggregate or something? I checked here but it still has two queries to be executed.

Example:

 db.test.remove({"type":"xyz"}).skip(500)

Something like this is not possible because Mongo DB does not allow skip and limit for remove. It shows error as follows.

TypeError: Object WriteResult({ "nRemoved" : 10 }) has no method 'skip' at (shell):1:32

If I have to purge some logs, I have to execute multiple queries one for finding the sorted nth element's _id (when I have to skip n) and then have a $lt or $gt query to delete anything before/after that time.

Is there any other provisions to reduce the number of queries executed?

Community
  • 1
  • 1
Sree Karthik S R
  • 335
  • 2
  • 3
  • 10

0 Answers0