Database

MongoDB has a find method that works absolutely like SQL’s WHERE.

This is how you show rows in MongoDB

> db.books.find()
{ "_id" : ObjectId("5d5e1c357545de885fa391fb"), "title" : "Book Title", "category" : "Fiction", "tags" : [ "children", "fantasy" ], "user" : { "name" : "Sophia", "status" : "author" }, "date" : "Thu Aug 22 2019 12:38:12 GMT+0800 (PST)" }
{ "_id" : ObjectId("5d5e21467545de885fa391fc"), "title" : "Book Title 2", "category" : "Fiction", "tags" : [ "teen", "fantasy" ], "user" : { "name" : "Ryan", "status" : "author" }, "date" : "Thu Aug 22 2019 12:59:50 GMT+0800 (PST)" }
{ "_id" : ObjectId("5d5e21a47545de885fa391fd"), "title" : "Book Title 3", "category" : "Non-Fiction", "tags" : [ "history", "documentary" ], "user" : { "name" : "Arthur", "status" : "author" }, "date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)" }
{ "_id" : ObjectId("5d5e21a47545de885fa391fe"), "title" : "Book Title 4", "category" : "Non-Fiction", "tags" : [ "legal" ], "user" : { "name" : "Manuel", "status" : "author" }, "date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)" }

If you only want to find books with the title, Book Title 4, you should add a parameter to the find method

> db.books.find({title: "Book Title 4"})
{ "_id" : ObjectId("5d5e21a47545de885fa391fe"), "title" : "Book Title 4", "category" : "Non-Fiction", "tags" : [ "legal" ], "user" : { "name" : "Manuel", "status" : "author" }, "date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)" }
> db.books.find({category: "Non-Fiction"})
{ "_id" : ObjectId("5d5e21a47545de885fa391fd"), "title" : "Book Title 3", "category" : "Non-Fiction", "tags" : [ "history", "documentary" ], "user" : { "name" : "Arthur", "status" : "author" }, "date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)" }
{ "_id" : ObjectId("5d5e21a47545de885fa391fe"), "title" : "Book Title 4", "category" : "Non-Fiction", "tags" : [ "legal" ], "user" : { "name" : "Manuel", "status" : "author" }, "date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)" }

You can use multiple keys to search for

> db.books.find({category: "Non-Fiction", title: "Book Title 3"})
{ "_id" : ObjectId("5d5e21a47545de885fa391fd"), "title" : "Book Title 3", "category" : "Non-Fiction", "tags" : [ "history", "documentary" ], "user" : { "name" : "Arthur", "status" : "author" }, "date" : "Thu Aug 22 2019 13:01:24 GMT+0800 (PST)" }