Last active
December 25, 2015 03:59
-
-
Save aymanfarhat/6914074 to your computer and use it in GitHub Desktop.
This file contains 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
var client = new DBClient(); | |
var db = client.setDatabase("test"); // If test doesnt exist creates it | |
var collection = db.getCollection("coll"); | |
// Find documents in a collection that match criteria | |
collection.selectDoc({name:"ayman"},function(data){ | |
// Callback for accessing and managing the returned data | |
}); | |
// Or find all | |
collection.selectDoc(function(data){ | |
}); | |
// Add a new document | |
collection.insert({"name":"joe","type":"student"}, function(data){ | |
// Access the reply and check out the ObjectId created on the server | |
}); | |
// Update an existing document: criteria, new data, and callback.. | |
collection.update({"name":"joe"},{"name":"afif",age:17},function(data){ | |
}); | |
// Delete document(s) | |
collection.remove({"_id":12345},function(data){ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment