ag-grid-mongo-query-builder
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "ag-grid-mongo-query-builder", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Utility to generate Mongo DB aggregation pipeline queries starting from AgGrid server side params", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -52,3 +52,3 @@ //const mongoose = require('mongoose'); | ||
const groupQuery = isGrouping ? buildGroupingQuery(groupKeys, rowGroupCols, valueCols, pivotCols,pivotMode) : []; | ||
const aggregationQuery = isAggregation ? buildAggregationQuery(valueCols) : []; | ||
//const aggregationQuery = isAggregation ? buildAggregationQuery(valueCols) : []; | ||
const sortQuery = isSorting ? buildSortQuery(sortModel) : null; | ||
@@ -65,3 +65,2 @@ const skipQuery = {'$skip': startRow}; | ||
...groupQuery, | ||
...aggregationQuery, | ||
sortQuery, | ||
@@ -119,3 +118,3 @@ skipQuery, | ||
const groupQuery = isGrouping ? buildGroupingQuery(groupKeys, rowGroupCols, valueCols, pivotCols,pivotMode) : []; | ||
const aggregationQuery = isAggregation ? buildAggregationQuery(valueCols) : []; | ||
//const aggregationQuery = isAggregation ? buildAggregationQuery(valueCols) : []; | ||
const countQuery = {$count: "totalRows"}; | ||
@@ -128,3 +127,2 @@ | ||
...groupQuery, | ||
...aggregationQuery, | ||
countQuery | ||
@@ -363,2 +361,3 @@ ].filter(stage => !!stage) | ||
console.log('group query2:',JSON.stringify(aggregationArray)); | ||
if(pivotMode) | ||
@@ -437,3 +436,3 @@ { | ||
const addFieldObj = {}; | ||
addFieldObj[rowGroupCols[excessIndex].id] = { $toString: "$_id" }; | ||
addFieldObj[rowGroupCols[excessIndex].id] = "$_id"; | ||
let addField = {"$addFields" : addFieldObj}; | ||
@@ -445,3 +444,3 @@ | ||
addField, | ||
projectionObj | ||
//projectionObj | ||
]; | ||
@@ -480,3 +479,3 @@ | ||
if(Object.keys(aggFunction).includes('aggFunc') && aggFunction['aggFunc']){ | ||
return { [aggFunction.id+"_"+aggFunction.aggFunc]: aggregateQuery(aggFunction)}; | ||
return { [aggFunction.id]: aggregateQuery(aggFunction)}; | ||
} | ||
@@ -492,9 +491,37 @@ }); | ||
switch (aggFunction.aggFunc) { | ||
case 'sum': return {$sum : "$"+aggFunction.id+""}; | ||
case 'sum': return { | ||
$sum : { | ||
"$convert": { | ||
input: "$"+aggFunction.id+"", | ||
to: "double", | ||
onError: 0, | ||
onNull: 0 | ||
}}}; | ||
case 'avg': return {$avg : "$"+aggFunction.id+""}; | ||
case 'avg': return { | ||
$avg : { | ||
"$convert": { | ||
input: "$"+aggFunction.id+"", | ||
to: "double", | ||
onError: 0, | ||
onNull: 0 | ||
}}}; | ||
case 'min' : return {$min : "$"+aggFunction.id+""}; | ||
case 'min' : return { | ||
$min : { | ||
"$convert": { | ||
input: "$"+aggFunction.id+"", | ||
to: "double", | ||
onError: 0, | ||
onNull: 0 | ||
}}}; | ||
case 'max' : return {$max : "$"+aggFunction.id+""}; | ||
case 'max' : return { | ||
$max : { | ||
"$convert": { | ||
input: "$"+aggFunction.id+"", | ||
to: "double", | ||
onError: 0, | ||
onNull: 0 | ||
}}}; | ||
@@ -505,3 +532,3 @@ case 'first' : return {$first : "$"+aggFunction.id+""}; | ||
case 'count' : return { 'count' : {$count : { } } }; // counts each doc | ||
case 'count' : return {$count : { } } ; // counts each doc | ||
} | ||
@@ -508,0 +535,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21409
455