Skip to content

Instantly share code, notes, and snippets.

@joepie91
Forked from anonymous/gist:362bbfb3125a220b6d51
Last active August 29, 2015 14:24
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 joepie91/b7d0272b5649426a9075 to your computer and use it in GitHub Desktop.
Save joepie91/b7d0272b5649426a9075 to your computer and use it in GitHub Desktop.
var Promise = require("bluebird");
var Article = Promise.promisifyAll(require("../wherever/the/article/model/is"));
var whichService = function whichService(input) {
// Keep in mind that you need to *return* the promise (not just the values in the callback!) if you want to use them as return-like values.
isDupe(input).then(function(data) {
console.log( data);
})
}
var isDupe = function isDupe(input) {
return Promise.try(function(){
return Article.findOneAsync({ params: input.params, taskSubType: input.taskSubType ,taskType: input.taskType});
}).then(function(result){
return true;
}).catch(function(err){
return false;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment