Skip to content

Instantly share code, notes, and snippets.

@Hanspagh
Created August 27, 2015 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Hanspagh/2ae449b1b46ab35605c3 to your computer and use it in GitHub Desktop.
Save Hanspagh/2ae449b1b46ab35605c3 to your computer and use it in GitHub Desktop.
function findOrCreate() {
db.find(id)
.then(function(r){
if(!r) {
db.create(id)
.then(r) {
return "success"
}
} else {
return "error"
}
})
function findOrCreate() {
var r = db.find(id);
if(!r) {
db.create(id);
return "success"
} else {
return "error";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment