-1

I am trying to add a dynamic condition in node.js through mongoose,

var date_and_cond = { $and: [] };
date_and_cond.$and.push({"rec_date": {$lt: "2018-08-08"}})
console.log(date_and_cond) 

I expect the above to print

{ '$and': [ { rec_date: {$lt: "2018-08-08"}

, so mongoose can execute that as a query but what I get is

{ '$and': [ { rec_date: [Object] } ] }

Sejista Carl
  • 91
  • 3
  • 13

1 Answers1

2

To log object details simply use JSON.stringify().

replace your console.log(date_and_cond) by console.log(JSON.stringify(date_and_cond)).

Hope this will help you :)

Luca Kiebel
  • 9,790
  • 7
  • 29
  • 44
A. Todkar
  • 353
  • 2
  • 10