0

I'm trying to make a simple query to get documents with the filtered collection made in the filter field. Bellow is the query and the result.

MongoDB result

My question is: Why the result returns "city_id" 0 and 1 if I've filtered only cities with the id 1?

  • Note that at the present time the Compass application does not support the "projection" capabilities of standard queries through the API, and also has no support for aggregation. Think of it as a "data explorer" and little beyond that. For prototyping "real queries" for your application, you need to use the `mongo` shell or even your programming language of choice instead. – Neil Lunn Apr 17 '18 at 13:02
  • Thanks for the tip! I've tried in the mongo console and used projection, and it works! For further, the query I used was: db.faqs.find({}, {pergunta: 1, resposta: 1, slug: 1, likes: {$elemMatch: {city_id: 1}}} ).pretty() – Danilo Buzar Apr 17 '18 at 13:56

0 Answers0