deletemany with lookup mongodb code example
Example: deletemany with lookup mongodb
var pipeline = [
{$lookup:{
from: "files",
localField: "files_id",
foreignField: "_id",
as: "file"
}
},
{$match:{
"file.uploadDate":
{
$lt: ISODate("2017-06-10T00:00:00.000Z")
}
}
}
];
var cursor = db.chunks.aggregate(pipeline);
var chunkIds = cursor.map(function (chunk) { return chunk._id; });
db.chunks.remove({"_id": { "$in": chunkIds }});