Skip to content

Instantly share code, notes, and snippets.

@L8D L8D/async.js

forked from Hanspagh/async.js
Last active Aug 27, 2015
Embed
What would you like to do?
function findOrCreate(id) {
return Promise.try(function() {
return db.find(id);
}).then(function(result) {
if (result == null) {
return db.create(id);
} else {
return result;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.