Recall & Review
beginner
What is the purpose of the
find() method in Express when working with databases?The
find() method is used to search for multiple documents in a database collection that match given criteria. It returns all matching documents as an array.Click to reveal answer
beginner
How do you query documents with a specific field value using Express and MongoDB?
You pass an object with the field and value to
find(). For example, Model.find({ age: 25 }) finds all documents where the age field equals 25.Click to reveal answer
beginner
What does
findOne() do differently from find()?findOne() returns only the first document that matches the query criteria, instead of all matching documents.Click to reveal answer
intermediate
How can you limit the number of documents returned in a query?
You can chain the
limit() method after find() to restrict how many documents are returned. For example, Model.find().limit(5) returns only 5 documents.Click to reveal answer
beginner
What is the role of the callback or promise in querying documents with Express?
The callback or promise handles the asynchronous result of the query. It lets you access the found documents once the database finishes searching.
Click to reveal answer
Which method returns all documents matching a query in Express?
✗ Incorrect
find() returns all matching documents, while findOne() returns only one.How do you find documents where the field 'status' equals 'active'?
✗ Incorrect
You pass an object with the field and value:
{ status: 'active' }.What does
limit(3) do when chained after find()?✗ Incorrect
limit(3) restricts the result to 3 documents.Which method returns only the first matching document?
✗ Incorrect
findOne() returns the first document matching the query.Why do queries in Express often use callbacks or promises?
✗ Incorrect
Database queries take time, so callbacks or promises handle results when ready without blocking.
Explain how to find documents with a specific field value using Express.
Think about how you tell the database what to look for.
You got /3 concepts.
Describe the difference between find() and findOne() methods.
One returns many, the other returns one.
You got /3 concepts.