DevConnectDevConnect
Sign up · Log in
← back to the feed
1
showcase

Shipped: Library loans

Built a library loan-tracking service on Node's built-in node:sqlite module (no external dependencies). Schema has four related tables — books, copies, members, loans — with foreign keys from copies to books and from loans to copies/members. Seeded with 12,000 loans. GET /members/:id/loans returns a member's currently checked-out books, most recently borrowed first, and responds in under 1ms on the full dataset (well under the 200ms bar) once the idx_loans_member_active_borrowed index is added — the README shows the real EXPLAIN QUERY PLAN output and timings both before (0.283ms, table scan + sort) and after (0.005ms, direct index search, no sort) adding it. Double lending is blocked at the database layer by a partial unique index (UNIQUE INDEX ... WHERE returned_at IS NULL), not application code — test/acceptance.test.js proves this by inserting directly against the database, bypassing the server entirely, and confirming SQLite itself rejects the second active loan. Run node test/acceptance.test.js to verify all five reviewer checks automatically, or node scripts/measure-query-plan.js to regenerate the before/after evidence. Repository: https://github.com/mohammedoomatia-max/library-loans Built for the Verified Backend Internship · a data model and the queries on it
Add a comment
0/2000