From the course: Learning MongoDB

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Using .find() to query documents

Using .find() to query documents - MongoDB Tutorial

From the course: Learning MongoDB

Using .find() to query documents

- [Instructor] The find command is one of the most basic MongoDB commands and acts much like a SELECT statement in SQL. Let's learn how to use find to query our recipe documents and find specific recipes. The first parameter for find is a document. Not the document that you're trying to match but rather a query document. If you pass an empty query document that'll match all documents. The default is an empty document. For example, if we do DB dot recipes dot find and don't pass anything, we'll get a whole bunch of stuff back. If we ask for something specific, like where the title is equal to tacos, I will get just one recipe back. Now to make that look a little nicer I can add on to the end an extra little command called pretty. And now this is formatted in a much more readable fashion. We can also do conditionals. So if we wanted to match more than one thing, for example, not just the title but also the cook time…

Contents