Grokking MongoDB
Vote

0% completed

​

Querying MongoDB Using Node.js

Calling collection.find({}) in Node.js sends nothing to the server. The driver only prepares the query, and it sends the request when your code asks for the results. This behavior explains why reading many documents takes one more step than reading a single document.

We will query one small collection of people, using the same testDB database and testCollection collection as the connection program. We read one document first and then all of them, and after that we add a filter, an order, a limit and a choice of fields.

Sample Data

Create a file named `seed.js

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content