-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
ποΈ Migrate Todos to PostgreSQL Database Storage
π Overview
Currently, todo items are stored in memory using the mock-todos.ts utilities. Update the backend so that all todo operations persist data in a PostgreSQL database instead of memory, making todos available across restarts and multiple users (no authentication needed).
Replace all existing usages of the mock data functions (getTodos, getTodoById, createTodo, updateTodo, toggleTodo, deleteTodo) with equivalent logic that reads/writes to Postgres via a Node.js database client of your choice (e.g., pg, Prisma, etc.).
Note: Authentication is NOT in scope. You may pick any PostgreSQL client/tooling.
π― Acceptance Criteria
- All endpoints in
app/api/todos/and subroutes persist/read todos in a PostgreSQL database (not memory) - Database stores at least:
id(primary key),text(string),completed(boolean),createdAt, andupdatedAt - Supports:
- Listing all todos (
GET /api/todos) - Creating a new todo (
POST /api/todos) - Fetching a single todo (
GET /api/todos/[id]) - Editing a todo (
PUT /api/todos/[id]) - Deleting a todo (
DELETE /api/todos/[id]) - Toggling a todoβs completed state (
PATCH /api/todos/[id]/toggle)
- Listing all todos (
- Uses environment variables for database credentials
- Provides an SQL schema or migration file, and brief setup instructions
π§ Technical Requirements
- Use PostgreSQL 17+ (local install or Docker)
- Use a Node.js database client that supports Postgres (your choice), e.g.:
pg(postgres)- Prisma
- ...
- All existing API routes should preserve their current response format and validation logic
- Error handling must be retained for non-existent IDs and unexpected failures
π« Out of Scope
- Authentication/authorization (all API endpoints remain public)
- User-specific todo lists or multi-user support
- Cloud database hosting or deployment
- Schema migrations beyond the minimum required for todos
π Resources
- PostgreSQL Official Documentation
- node-postgres Docs
- Prisma Getting Started
- Drizzle ORM Docs
- Next.js API Routes Docs
π‘ Tips
- Use async/await for DB operations
- Add seed data if desired, but not required
- Document your SQL schema & migration steps in a README or a migration file
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request