import { Knex } from 'knex'; import { BaseRepository } from './base-repository'; import { Step } from '@shared/index'; export class StepRepository extends BaseRepository { constructor(db: Knex) { super(db, 'steps'); } async findByTaskId(taskId: number): Promise { return await this.db(this.tableName) .where('task_id', taskId) .orderBy('order') .select('*'); } async incrementPrintCount(id: number): Promise { const step = await this.findById(id); if (!step) return false; return await this.update(id, { print_count: step.print_count + 1, last_printed_at: new Date() }); } }