Advertisement
Guest User

javascript database callback and promise

a guest
Apr 18th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // list of 'employee' objects
  2. var objs = getList();
  3. Promise.all(objs.map(function(o) {
  4.     // use 'node-orm2'.find() or 'node-mysql'.query()
  5.     // if no similar exists, return it (some where condition)
  6.    
  7.     // problem is find() and query() have their own 'callback'
  8.     // where do I return 'o' for the 'Array.map()'?
  9.    
  10. }).then(function(filteredObjs) {
  11.     // do whatever I want
  12. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement