export class ProjectRepository {
    db;
    stmts;
    constructor(db) {
        this.db = db;
        this.stmts = {
            create: this.db.prepare(`
        INSERT INTO projects (name, path, language, framework)
        VALUES (@name, @path, @language, @framework)
      `),
            getById: this.db.prepare(`
        SELECT * FROM projects WHERE id = ?
      `),
            update: this.db.prepare(`
        UPDATE projects
        SET name = COALESCE(@name, name),
            path = COALESCE(@path, path),
            language = COALESCE(@language, language),
            framework = COALESCE(@framework, framework),
            updated_at = datetime('now')
        WHERE id = @id
      `),
            delete: this.db.prepare(`
        DELETE FROM projects WHERE id = ?
      `),
            findByName: this.db.prepare(`
        SELECT * FROM projects WHERE name = ?
      `),
            findByPath: this.db.prepare(`
        SELECT * FROM projects WHERE path = ?
      `),
            getAll: this.db.prepare(`
        SELECT * FROM projects ORDER BY name
      `),
        };
    }
    create(data) {
        const result = this.stmts.create.run({
            name: data.name,
            path: data.path ?? null,
            language: data.language ?? null,
            framework: data.framework ?? null,
        });
        return result.lastInsertRowid;
    }
    getById(id) {
        return this.stmts.getById.get(id);
    }
    update(id, data) {
        this.stmts.update.run({
            id,
            name: data.name ?? null,
            path: data.path ?? null,
            language: data.language ?? null,
            framework: data.framework ?? null,
            updated_at: data.updated_at ?? null,
        });
    }
    delete(id) {
        this.stmts.delete.run(id);
    }
    findByName(name) {
        return this.stmts.findByName.get(name);
    }
    findByPath(path) {
        return this.stmts.findByPath.get(path);
    }
    getAll() {
        return this.stmts.getAll.all();
    }
}
//# sourceMappingURL=project.repository.js.map