Introduction to MongoDB-MongoDB Aggregation-Lesson3

Hello everyone.
In the lab practice there is a wrong solved code. The solved code in the section “Review and Solved Code” is:

db.sightings.aggregate([
  {
    $sort: {
        'location.latitude': -1
    }
  }, {
    $limit: 4
  }
])

but in the collection sightings, the field “location” is an array with two elements, “type” and “coordinates”. The location.latitude doesn’t exist.
It is possible to check?
Best regards
Enrico

3 Likes

I agree something is broken because there are only 6 documents and none has a “latitude/longitude” distinction: db.sightings.find().count()

It is either:

  • data set is broken in the playground
  • the challenge is itself wrong as can be deduced.
1 Like