In the Find Project exercise, we're supposed to return documents with only the name and age properties using the MongoDB Node.js Driver.
The example provided shows a projection argument to the collection's find() method and references the documentation for this method as a resource link. However, this is the method's implementation in Mongo Shell. The find() method in NodeJS doesn't have a projection argument. Instead, a projection is applied using the project() method on the Cursor returned by find().
In the Find Project exercise, we're supposed to return documents with only the name and age properties using the MongoDB Node.js Driver.
The example provided shows a projection argument to the collection's
find()
method and references the documentation for this method as a resource link. However, this is the method's implementation in Mongo Shell. Thefind()
method in NodeJS doesn't have a projection argument. Instead, a projection is applied using theproject()
method on the Cursor returned byfind()
.An accurate example would look like this:
References: