Skip to content

Instantly share code, notes, and snippets.

@aymanfarhat
Last active December 25, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aymanfarhat/6914074 to your computer and use it in GitHub Desktop.
Save aymanfarhat/6914074 to your computer and use it in GitHub Desktop.
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