@@ -13,10 +13,12 @@ const aggregator = [
13
13
output : {
14
14
rowNumber : {
15
15
$documentNumber : { } ,
16
- window : [ 'unbounded' , 'current' ] ,
16
+ // window: ['unbounded', 'current'],
17
17
} ,
18
18
} ,
19
19
} ,
20
+ } ,
21
+ {
20
22
$match : {
21
23
rowNumber : { $lte : 50 } ,
22
24
} ,
@@ -27,10 +29,14 @@ const aggregator = [
27
29
// Create an aggregator based on the aggregator variable
28
30
// return the result
29
31
fetchData . mongoFetch = async function ( serviceName ) {
30
- const testModel = HealthModelFunc ( serviceName ) ;
31
- let result = await testModel . aggregate ( aggregator ) ;
32
- result = [ { [ serviceName ] : result } ] ;
33
- return result ;
32
+ try {
33
+ const testModel = HealthModelFunc ( serviceName ) ;
34
+ let result = await testModel . aggregate ( aggregator ) ;
35
+ result = [ { [ serviceName ] : result } ] ;
36
+ return result ;
37
+ } catch ( error ) {
38
+ console . log ( 'Aggregation error in mongoFetch(): ' , error ) ;
39
+ }
34
40
} ;
35
41
36
42
fetchData . postgresFetch = async function ( serviceName , pool ) {
@@ -53,12 +59,11 @@ fetchData.postgresFetch = async function (serviceName, pool) {
53
59
;` ;
54
60
55
61
let result = await pool . query ( query ) ;
56
- console . log ( " result.rows in dataHelpers postgresFetch:" , JSON . stringify ( result . rows ) ) ;
62
+ console . log ( ' result.rows in dataHelpers postgresFetch:' , JSON . stringify ( result . rows ) ) ;
57
63
result = result . rows ;
58
64
result = [ { [ serviceName ] : result } ] ;
59
- console . log ( " result with servicename in dataHelpers postgresFetch:" , JSON . stringify ( result ) ) ;
65
+ console . log ( ' result with servicename in dataHelpers postgresFetch:' , JSON . stringify ( result ) ) ;
60
66
return result ;
61
67
} ;
62
68
63
69
export { fetchData } ;
64
-
0 commit comments