Created
October 31, 2014 03:39
-
-
Save djyde/86ce60a37ea6dd5f25fc to your computer and use it in GitHub Desktop.
StoreDB CRUD
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
//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