Skip to content

Instantly share code, notes, and snippets.

@djyde
Created October 31, 2014 03:39
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 djyde/86ce60a37ea6dd5f25fc to your computer and use it in GitHub Desktop.
Save djyde/86ce60a37ea6dd5f25fc to your computer and use it in GitHub Desktop.
StoreDB CRUD
//insert
storedb('players').insert({"name":"Randy","sex":"male","score":20},function(err,result){
if(!err){
//do sth...
} else //do sth...
})
//find
storedb('players').find({"name":"Randy"},function(err,result){
if(!err){
//use result to do sth...
} else //do sth...
})
//find all
storedb('players').find()
//update with selector
storedb('players').update({"name":"Randy"},{"$inc":{"score":"10"}},function(err){
if(!err){
//do sth...
} else //do sth...
})
//remove
storedb('players').remove({"name":"Randy"},function(err){
if(!err){
//do sth...
} else //do sth...
})
//remov all
storedb('players').remove()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment