Index for mongo query

27 views Asked by At

I have a query with 3 fields, the id of the 'category', a 'start_date' from which to take major values, a 'stop_date' from which to take minor values. Results should be sorted by 'start_date', oldest to newest.

  return MyCollection.find({'category': categoryId, 
                            'start_date': {$gte: start}, 
                            'stop_date': {$lt: stop}}, 
                            {sort: {"start_date": 1}},
                            {fields: {  id: 1,
                                        email: 1,
                                        start_date: 1,
                                        stop_date: 1,
                                        duration: 1
                            }
  });
  

Is this index correct?

  {
    "category" : 1,
    "start_date" : 1,
    "stop_date" : 1
  }
  

Thanks for the help

0

There are 0 answers