File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import {
1515 getCommonIds ,
1616 getLastSeqId
1717} from '../mongo/models/source' ;
18- import { IAggregationCallback } from '../types' ;
18+ import { IAggregationCallback , MaybePromiseBool } from '../types' ;
1919import { debugUtil } from '../util/debug' ;
2020
2121const debug = debugUtil ( 'aggregation' ) ;
@@ -47,8 +47,8 @@ export async function aggregate(conf: IAggregationConfigElement) {
4747 maxSeqIds [ sourceName ] = lastCid
4848 ? lastCid . sequentialID
4949 : lastSourceSeq
50- ? lastSourceSeq . sequentialID
51- : 0 ;
50+ ? lastSourceSeq . sequentialID
51+ : 0 ;
5252 const cids = ids . map ( ( cid ) => cid . commonID ) ;
5353 commonIds = commonIds . concat ( cids ) ;
5454 }
@@ -116,10 +116,10 @@ async function aggregateValue(
116116 commonId : string
117117) {
118118 const result = { } ;
119- let accept : void | boolean = true ;
119+ let accept : MaybePromiseBool = true ;
120120 for ( const key in filter ) {
121121 if ( data [ key ] ) {
122- accept = await Promise . resolve (
122+ accept = await Promise . resolve < MaybePromiseBool > (
123123 filter [ key ] . call (
124124 null ,
125125 data [ key ] . map ( ( d ) => d . data ) ,
Original file line number Diff line number Diff line change @@ -56,12 +56,18 @@ export interface IAggregationConfigFile<AggregationResultType = any> {
5656 chunkSize ?: number ;
5757}
5858
59- export type IAggregationCallback <
60- SourceDataType extends object = any ,
61- AggregationResult = any
59+ export type MaybePromiseBool =
60+ | void
61+ | boolean
62+ | Promise < void >
63+ | Promise < boolean > ;
64+
65+ export type IAggregationCallback <
66+ SourceDataType extends object = any ,
67+ AggregationResult = any
6268> = (
6369 data : SourceDataType [ ] ,
6470 result : AggregationResult ,
6571 commonID : string ,
6672 ids : string [ ]
67- ) => void | boolean ;
73+ ) => MaybePromiseBool ;
You can’t perform that action at this time.
0 commit comments