Last active
February 2, 2016 14:40
-
-
Save bjarneo/9024f271a2c98fda3c38 to your computer and use it in GitHub Desktop.
MongoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove N documents from collection | |
var idsToRemove = db.collection.find({ "query": "to perform" }).limit(10000).sort({ "_id": -1 }).toArray().map(function(doc) { return doc._id; }); | |
db.collection.remove({ "_id": { $in: idsToRemove }}) | |
// Update | |
db.collection.update({ "_id": { $set: { "test": "update" } } }); | |
// Get current operations | |
db.currentOp(); | |
// Count shortcurt | |
db.collection.count({ "name": "woop" }); | |
// Sort by natural order | |
db.collection.find({}).limit(10).sort({ $natural: -1 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment