Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. function qDB1(status_id) {
  2. return KnexDB1
  3. .select()
  4. .from('table1')
  5. .where({
  6. status: status_id
  7. })
  8. .orderBy('date')
  9. .catch(function(err) {
  10. console.log(err);
  11. });
  12. }
  13.  
  14. function qDB2 () {
  15. var dateStart=Moment().format('L');
  16. var dateEnd=Moment().add(1, 'days').format('L');
  17. return KnexImc
  18. .raw("EXEC SP_DB2 'QU', '"+dateStart+"','"+dateEnd+"'")
  19. .catch(function(err) {
  20. console.log(err);
  21. });
  22. }
  23.  
  24. QueryRepo.prototype.select = function(status_id) {
  25.  
  26. if ( !status_id) {
  27. status_id=1;
  28. }
  29. var results = [];
  30.  
  31. qDB1(status_id)
  32. .then(function (res) {
  33. for(var idx = 0; idx < res.length; idx++){
  34. console.log(res[idx]);
  35. results.push(res[idx]);
  36. }
  37. });
  38. qDB2()
  39. .then(function (res) {
  40. for(var idx2 = 0; idx2 < res.length; idx2++){
  41. console.log(res[idx2]);
  42. results.push(res[idx2]);
  43. }
  44. });
  45.  
  46. return Promise.all(results);
  47.  
  48. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement