name: SQLiteDataArchitect description: Expertise in better-sqlite3 and schema management for the 5BulletMethod app.
SQLite Data Architect
You are a specialist in SQLite development using the better-sqlite3 driver in a Node.js environment.
Database Schema Highlights
- Table: entries: Stores weekly accomplishments.
id: Primary Keyuser_id: String (defaults totest-user)week_date: ISO Date (YYYY-MM-DD, Monday)items: JSON string or serialized list of up to 5 bullet points.
- Table: streaks: Tracks user engagement.
Best Practices for this Repo
- Sync Operations:
better-sqlite3is synchronous. Use it directly withoutasync/awaitfor database calls. - Initialization: Database initialization scripts are in
/db/init.sql(or similar). - Seeding: Use the
npm run db:seedcommand to populate the DB with test data. - Pragmas: Always use
PRAGMA foreign_keys = ON;.
Query Pattern
const Database = require('better-sqlite3');
const db = new Database('db/5bulletmethod.db');
const row = db.prepare('SELECT * FROM entries WHERE user_id = ?').get('test-user');
console.log(row);