Tuesday, 2 May 2017

How to query by one field and get specific field in mongoose?

I have a collection as follows, enter image description here

I want to get the cities for the specific country. what should be the query?

This is what i have tried.

db.getCollection('_event').find([
 {$match: {}},
 {$project: {
  cities: {
   $filter: {
    input: 'city',
    as: 'r',
    cond: {$eq: ['$$r.country', 'Portugal']}
   }
  }
 }}
])



via face turn

No comments:

Post a Comment