Backend live coding · 45 minutes
Paginated search endpoint
In 45 minutes, with the interviewer watching, add a search endpoint to a small service that already has a products table: id, name, category, price and created_at. GET /products/search takes a text query, an optional category and a price range, and returns one page of results with a cursor for the next page. Results are ordered by created_at, newest first. Use the language and database you know best; an in-memory SQLite database seeded with a few hundred rows is fine. Talk while you work: say what you check and why.
Requirements
- GET /products/search?q=&category=&minPrice=&maxPrice=&limit=&cursor=
- Validates the parameters: limit between 1 and 100 with a default, prices are numbers, minPrice is not above maxPrice
- Builds the query with parameters, never by joining user text into SQL
- Orders by created_at and id, and pages with a cursor on those two values, not with OFFSET
- Returns { items, nextCursor }, with nextCursor null on the last page
- Explains which index the query needs, and creates it
What reviewers look for
What reviewers look for, the checklist and the stretch goals opens with a year in the app. What a year includes