Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var cursor = db.engagementMetric.aggregate([
{ "$project": {
"createdAt": "$createdAt"
}}
])
var requests = [];
cursor.forEach(document => {
requests.push( {
'updateOne': {
'filter': { '_id': document._id },
'update': { '$set': { 'buildDate': document.createdAt } }
}
});
if (requests.length === 500) {
//Execute per 500 operations and re-init
db.engagementMetric.bulkWrite(requests);
requests = [];
}
});
if(requests.length > 0) {
db.engagementMetric.bulkWrite(requests);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment