CRUD Operations: Find One
đź“‹ Lab Reference
Associated Lab File: crud-2.lab.js
🚀 Goal: Instantly Retrieve a Single Document
Your platform is growing, and now your users want more than just a list—they want details! Imagine a guest clicking on a property to see every photo, amenity, and review. As the backend engineer, it’s your job to deliver that information instantly and accurately.
In this exercise, you’ll unlock the power of MongoDB’s findOne to fetch exactly what your users need, right when they need it. This is the magic behind every detail page—making sure guests can dive deep into any listing with a single click.
đź§© Exercise: Find One Document
-
Open the File
Navigate toserver/src/lab/and opencrud-2.lab.js. -
Locate the Function
Find thecrudOneDocumentfunction in the file. -
Shape the Query
- Implement the function to find one document where
_idequals the providedidparameter. - Return the complete document that matches this criteria.
- Implement the function to find one document where
🚦 Test Your API
- Go to
server/src/lab/rest-lab. - Open
crud-2-one-lab.http. - Click Send Request to execute the API call.

- Verify the response returns the single document you requested.
🖥️ Frontend Validation
Important:
To check if your implementation works, go to the homepage of the app and select a listing.
This will open the details page for that property and trigger your new API code.
- When you select a listing, all the details for that property should appear—fast, focused, and flawless.
- Check Exercise Status:
Look for the exercise toggle on the details page. If it shows green, your implementation is correct!
With this step, you’re not just retrieving data—you’re bringing each listing to life for your users.
Ready to deliver the details that make your platform shine? Let’s get started!

Ready for the next challenge?
Continue to: CRUD: Exercise 3