MongoDB query to show a column within an array

Viewed 23

I wanted to display the grade and date from the database provided to me which is lists of restaurants within New York and its boroughs. I can show the grades but when I try to show the dates that are greater than 2012, I'm having trouble. Here's the query that I used:

db.restaurants.find(
  {
    'grades.0.grade': 'A',
    'grades.1.grade': 'A',
    'grades.2.grade': 'A',
    'grades.0.date': { $gt: 2013 },
  },
  { borough: 1, cuisine: 1, name: 1, grades: 1, 'grades.grade': 1 }
);

The first page of the db

Page when we go to grades

Page when we go to a column, in this case 0

How do I show them in a query?

EDIT: Here's the value within one cell of the date column: "2014-04-21T00:00:00.000+0000".

0 Answers
Related