

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Storage
incomplete
2: Drizzle ORM
incomplete
3: Drizzle Queries
incomplete
4: Automatic Migrations
incomplete
5: Database Review
incomplete
6: Create User
incomplete
7: Create Chirp
incomplete
8: Collections and Singletons
incomplete
9: Get All Chirps
incomplete
10: Get Chirp
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Now we need a way to look up a single chirp by its ID. You might be thinking:
"If I can get all the chirps, why do I need a way to get just one?"
Imagine there are 10,000 chirps in the database - no, imagine 10,000,000,000! We'll obviously need to change our GET /api/chirps endpoint to only return a subset of chirps at a time.
However, our users will still need a way to view a single chirp - for example, maybe they have a link directly to it.
GET /api/chirps/94b7e44c-3604-42e3-bef7-ebfcc3efff8f
You can get the string value of the path parameter with the Request.params field.
You can use the eq operator from Drizzle to find a single chirp by its ID.
{
"id": "94b7e44c-3604-42e3-bef7-ebfcc3efff8f",
"createdAt": "2021-01-01T00:00:00Z",
"updatedAt": "2021-01-01T00:00:00Z",
"body": "fr? no clowning?",
"userId": "123e4567-e89b-12d3-a456-426614174000"
}
Run and submit the CLI tests.