2

I am learning MongoDB by myself. I am following all the official guides as well as watching videos and I am practicing on a movie database. Each document has an array "crew" with a "give_name" (not given_name) property and an array "ratings" with a "rating_date" property. I want to query movies that starring Leonardo DiCaprio rated after 2010-01-01. The below line of code seems to be correct to me according to what I have seen, however, it returns an error

clone(t={}){const r=t.loc||{};return e({loc:new Position("line"in r?r.line:this.loc.line,"column"in r?r.column:...<omitted>...)} could not be cloned.

Could anyone show me where is the mistake? Because I have been staring at this string for a good couple of hours and made different changes so far unsuccesfully. Thank you.

db.movie.find({
  "$and": [
  {"crew": {"$elemMatch" {
    "give_name": "Leonardo DiCaprio"}}},
  {"ratings": {"$elemMatch": {
    "rating_date": {"$gte": ISODate("2010-01-01")}
  }}}]
},
{
  "_id": 0,
  "crew.give_name.$": 1,
  "ratings.rating_date.$": 1
})
1
  • 1
    You missed the colon: {"crew": {"$elemMatch" { must be {"crew": {"$elemMatch": { Maybe use a proper JavaScript editor like Visual Studio Code - it is open-source! Dec 2, 2022 at 16:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.