I tried query movies in shell with the script below:
db.movies.find({ countries: { $in: ["Russia", "Japan", "Mexico"] }}, { title: 1 })
It works.
However, in the node.js mongodb driver, it takes extremely long time to execute and returns all fields inside movies collection.
movies.find({ countries: { $in: ["Russia", "Japan", "Mexico"] }}, { projection: { title: 1 }})
The missing piece is the projection:
. I thought the shell runs the same command as node.js, since they are both javascript.
Can someone explain to me what the difference between these two, and what else are not the same?