All files / src/repositories/scan checklist-config.repository.ts

70% Statements 7/10
100% Branches 0/0
0% Functions 0/2
62.5% Lines 5/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 361x 1x 1x 1x   1x                                                            
import {inject} from '@loopback/core';
import {DefaultCrudRepository} from '@loopback/repository';
import {LogChainDataSource} from '@logchain/datasources';
import {ChecklistConfig, ChecklistConfigRelations} from '@logchain/models/scan/checklist-config.model';
 
export class ChecklistConfigRepository extends DefaultCrudRepository<
  ChecklistConfig,
  typeof ChecklistConfig.prototype.id,
  ChecklistConfigRelations
> {
  constructor(@inject('datasources.logchain') dataSource: LogChainDataSource) {
    super(ChecklistConfig, dataSource);
  }
 
  async findByStatus(status: number): Promise<ChecklistConfig[]> {
    const result = await this.execute(
      `
      SELECT
        id,
        status,
        key,
        text,
        required,
        created_at,
        updated_at
      FROM checklist_config
      WHERE status = $1
      ORDER BY id ASC
      `,
      [status],
    );
 
    return result as ChecklistConfig[];
  }
}