Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. var Promise = require("bluebird");
  2. var Article = Promise.promisifyAll(require("../wherever/the/article/model/is"));
  3.  
  4. var whichService = function whichService(input) {
  5. // 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.
  6. isDupe(input).then(function(data) {
  7. console.log( data);
  8. })
  9. }
  10.  
  11. var isDupe = function isDupe(input) {
  12. return Promise.try(function(){
  13. return Article.findOneAsync({ params: input.params, taskSubType: input.taskSubType ,taskType: input.taskType});
  14. }).then(function(result){
  15. return true;
  16. }).catch(function(err){
  17. return false;
  18. });
  19. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement