import { RepositoryBase, IRepositoryBase } from '@tomei/general'; import { AgreementModel } from '../../models/agreement.entity'; export class AgreementRepository extends RepositoryBase implements IRepositoryBase { constructor() { super(AgreementModel); } async findByPk( id: string, transaction?: any, ): Promise { try { const result = await AgreementModel.findByPk(id, { transaction: transaction, }); return result; } catch (error) { throw new Error(`An Error occured when fetching : ${error.message}`); } } async delete(AgreementNo: string, dbTransaction?: any) { try { const options = { where: { AgreementNo, }, transaction: dbTransaction, }; await AgreementModel.destroy(options); } catch (error) { throw new Error(`An Error occured when delete : ${error.message}`); } } async findAndCountAll(options?: any) { try { let Agreements: any; if (options) { Agreements = await AgreementModel.findAndCountAll(options); } else { Agreements = await AgreementModel.findAndCountAll(); } return Agreements; } catch (error) { throw new Error(`An Error occured when retriving : ${error.message}`); } } }