import { LedgerHeader } from "../model" ; import { LedgerHeaderFactory } from "../model/factories" ; import { BaseStorage } from "./base" ; export class LedgersStorage extends BaseStorage { public static async minSeq ( ) { return new LedgersStorage ( ) . minSeq ( ) ; } public static async maxSeq ( ) { return new LedgersStorage ( ) . maxSeq ( ) ; } public static async findBySeq ( seq ) { const header = await new LedgersStorage ( ) . addTerm ( { seq } ) . one ( ) ; return header ? ( header as LedgerHeader ) : null ; } public async minSeq ( ) { const aggregations = await this . aggregation ( { minSeq : { min : { field : "seq" } } } ) ; return aggregations . minSeq . value ; } public async maxSeq ( ) { const aggregations = await this . aggregation ( { maxSeq : { max : { field : "seq" } } } ) ; return aggregations . maxSeq . value ; } protected get elasticIndexName ( ) { return "ledger" ; } protected convertRawDoc ( doc ) { return LedgerHeaderFactory . fromStorage ( doc ) ; } }