Here I have a solution to avoid multiple requests to delete loops and old documents.
You can easily create a new idea manually using something like: _id:ObjectId() But knowing that Mongo will automatically assign _id in case of absence, you can use the aggregate to create $project containing all the fields of your document, but skip the _id field . Then you can save it with $out
So if your document:
{ "_id":ObjectId("5b5ed345cfbce6787588e480"), "title": "foo", "description": "bar" }
Then your request will be:
db.getCollection('myCollection').aggregate([ {$match: {_id: ObjectId("5b5ed345cfbce6787588e480")} } {$project: { title: '$title', description: '$description' } }, {$out: 'myCollection'} ])
Florent Arlandis Jul 31. '18 at 13:23 2018-07-31 13:23
source share