Writing a query to fetch completed todos

To get this done, inside of Atom, we're going to make a change to how we call find. Instead of passing in 0 arguments, we're going to pass in 1. This is what's known as our query. We can start specifying how we want to query the Todos collection. For example, maybe we want to query only Todos that have a completed value equal to false. All we have to do to query by value is set up the key-value pairs, as shown here:

db.collection('Todos').find({completed: false}).toArray().then((docs) => {

If I rerun our script over in the Terminal after shutting it down, we get just our one Todo item:

We have our item ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.