Prince Asokan
Prince Asokan

Reputation: 307

Meteor find().fetch() with multiple and condition not working

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
      }
      ]
      }

Upvotes: 2

Views: 307

Answers (1)

blueren
blueren

Reputation: 2870

Looking at your query, you are trying to find all those appointments which is between timePeriod.from and timePeriod.to and where url is boaseenterprises.ezvisitor.com

appointment.find({
    appointmentDate: {$gte:timeperiod.from},
    appointmentDate: {$lt:timePeriod.to},
    url : "boaseenterprises.ezvisitor.com"
}).fetch();

Upvotes: 1

Related Questions