![Advanced Node.js Development](https://wfqqreader-1252317822.image.myqcloud.com/cover/39/36700039/b_36700039.jpg)
Fetching todos in Robomongo file
Now, we're going to create a new file based off of mongodb-connect. In this new file, instead of inserting records, we'll fetch records from the database. I'm going to create a duplicate, calling this new file mongodb-find, because find is the method we're going to use to query that database. Next, we can go ahead and remove all of the commented-out code that currently inserts records. Let's get started by trying to fetch all of the Todos out of our Todos collection. Now, if I head over to Robomongo and open up the Todos collection, we have just one record:
![](https://epubservercos.yuewen.com/8EB3DA/19470395308895506/epubprivate/OEBPS/Images/c2f51586-1c3b-4789-bdef-5628eaa6ce3a.png?sign=1738839155-toYFoAk2HhFhesNtlR0OLrUzJ4a1Xi7P-0-cc7b633a80dfcb18cc553dbfcb3dde18)
In order to make this querying a little more interesting, we're going to go ahead and add a second one. Right in the Robomongo window, I can click Insert Document. Robomongo can delete, insert, update, and read all of your documents, and this makes it a fantastic tool for debugging. We can add a new document on the fly, with a text property equal to Walk the dog, and we can also tack on a completed value. I'm going to set completed equal to false:
{
text : "Walk the dog",
completed : false
}
Now by default, we're not going to provide an _id prop. This is going to let MongoDB automatically generate that ObjectId, and right here we have our two Todos:
![](https://epubservercos.yuewen.com/8EB3DA/19470395308895506/epubprivate/OEBPS/Images/98401436-3619-4b3e-ade6-1924c766d1fe.png?sign=1738839155-vRrWICVcRGiLkh38K8hun5zLP5UDqZIB-0-a97a73f719849df8466a70900838f8f9)
With this in place, let's go ahead and run our first query inside of Atom.