Find().fetch() with multiple conditions not working

Hi,

I’m trying to fetch some data from appointment table. But when execute the following code, data not fetching. In my mongo I have data with matching criteria. Any help would be appreciated advance.
Can anyone check the condition which I’m giving right or wrong.
var timePeriod = {

  to: 1512412200000,
  from: 1511807400000
}

var List= appointment.find({$and:[{‘appointmentDate’:{$gte:Number(timePeriod.from)}},{‘appointmentDate’:{lte:Number(timePeriod.to)}},{‘url’:{$eq:‘boaseenterprises.ezvisitor.com’}}]}).fetch();

mongo collection data
{
"_id" : “SpwCxi4CsxDFanvrf”,
“appointmentDate” : 1511952239000.0,
“appointmentTime” : 1511952239000.0,
“appointmentEndDate” : 1511955839000.0,
“appointmentEndTime” : 1511955839000.0,
“purpose” : “t”,
“hostName” : “boase”,
“status” : “pending”,
“hostId” : “Tct2pRanpHW5pju6A”,
“url” : “boaseenterprises.ezvisitor.com”,
“visitorsList” : [
{
“id” : “9i8u9tFwyuFi7xjmE”,
“name” : “test1”,
“signIn” : 0,
“signOut” : 0
}
]
}

Code formatting helps people to help you:

var timePeriod = {
  to: 1512412200000,
  from: 1511807400000
}

var List= appointment.find({
  $and: [
  {
    ‘appointmentDate’: {
      $gte:Number(timePeriod.from)
    }
  },
  {
    ‘appointmentDate’: {
      lte:Number(timePeriod.to)
    }
  }, {
    ‘url’: {
      $eq:‘boaseenterprises.ezvisitor.com1’
    }
  }
  ]
}).fetch();
mongo collection data
{
  "_id" : “SpwCxi4CsxDFanvrf”,
  “appointmentDate” : 1511952239000.0,
  “appointmentTime” : 1511952239000.0,
  “appointmentEndDate” : 1511955839000.0,
  “appointmentEndTime” : 1511955839000.0,
  “purpose” : “t”,
  “hostName” : “boase”,
  “status” : “pending”,
  “hostId” : “Tct2pRanpHW5pju6A”,
  “url” : “boaseenterprises.ezvisitor.com1”,
  “visitorsList” : [{
    “id” : “9i8u9tFwyuFi7xjmE”,
    “name” : “test1”,
    “signIn” : 0,
    “signOut” : 0
  }]
}
2 Likes

lte should be $lte

(didn’t look any further)

1 Like