Guest User

Untitled

a guest
Jan 3rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. exports.getJoinedTransactions = function(firmId, page, pageSize, billerId, matterId, words, billingStatus, cb) {
  2.  
  3. let firmIdToObjId = new mongoose.Types.ObjectId(global.user.firmId);
  4. let query = { firmId: firmIdToObjId };
  5.  
  6. if ( typeof billerId === "object" ) {
  7. billerId = new mongoose.Types.ObjectId(billerId);
  8. query.contactId = billerId;
  9. }
  10.  
  11. if ( typeof matterId === "object" ) {
  12. matterId = new mongoose.Types.ObjectId(matterId);
  13. query.matterId = matterId;
  14. }
  15.  
  16. ....
  17.  
  18. myAggregate = [
  19. { $sort: { date: -1 } },
  20. {
  21. $match: query
  22. },
  23.  
  24. ....
  25.  
  26. Transactions.aggregate(myAggregate).exec( function(err, transactions) {
  27.  
  28. if (err) {
  29. console.log(err);
  30. }
  31.  
  32. someVar = transactions.length;
  33.  
  34. ....
  35.  
  36. if (typeof billingStatus === "string" && billingStatus != "") {
  37.  
  38. if (billingStatus === "billed") {
  39. query.billId = { $not: null } ; <-- This does not work.
  40. } else if (billingStatus === "unbilled") {
  41. query.billId = null; <-- This works!
  42. }
  43. }
Add Comment
Please, Sign In to add comment