I am looking at the query in the notebook and also online in WP schools… I have some questions.
First… in the notebook they set the movies variable in the connection string… Where I am confused is according to notebook, I don’t need to stipulate any aggregation pipeline. (Hence I shouldn’t have to use &match)… It appears that python assumes the match portion as well as the projection as evident below.
# find all movies with Salma Hayek, but only project the "_id" and "title" fields
cursor = movies.find( { "cast": "Salma Hayek" }, { "title": 1 } )
print(dumps(cursor, indent=2))
Where I am confused is in the return statement in the db.py file.
return list(db.movies.find()).limit(1)
In the notebook mflix.movies is assigned to the variable movies…
My question is do I need to start my query with any of the following?
I am currently using this query
movie = {"countries": {"$in": countries}}, {"title": 1}
Do I need to start the query with
movie = db.movies.find(…), It seems a little redundant since it is in the return statement. I should just be able to define the query…
or perhaps movie = db.movies.aggregate([…])??
Where can I go to read on how to do this, or am I overthinking this?