java - Spring Mongo Query, remove objects in collection matching list -




how can remove objects mongo collection, passing list of objects remove: using spring , mongo repository, below code:

 public void removedocuments(list<payloadlogs> listlogs){       string collectionname = mongotemplate.getcollectionname(logs.class);      query removequery = query.query(criteria.where("typehash").in(listlogs));  // not removes documents.     this.mongotemplate.findallandremove(removequery, payloadlogs.class, collectionname); } 

query log:

db.getcollection('payloadlogs').find({ "creativehash": {     "$in": [{         "creativehash": "21540209fa87504bbbb0dd173c41d742",         "lastaccessedat": null,         ....     }] } 

});

i think helpful, add ids list , remove ids

  basicdbobject query = new basicdbobject();   list<integer> list = new arraylist<integer>();   list.add(10004);   list.add(10005);   query.put("_id", new basicdbobject("$in", list));   collection.remove(query); 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -