ag-grid-mongo-query-builder
Advanced tools
Comparing version 0.3.7 to 0.3.8
{ | ||
"name": "ag-grid-mongo-query-builder", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"description": "Utility to generate Mongo DB aggregation pipeline queries starting from AgGrid server side params", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -939,32 +939,49 @@ //const mongoose = require('mongoose'); | ||
const response = await Promise.all(requests); | ||
console.log('------Export Response Length'); | ||
console.log(response.length); | ||
if(response && response.length > 0) { | ||
console.log('------------Keys'); | ||
console.log(keys); | ||
response.map(eachRes => { | ||
console.log('------Each batch Response Length'); | ||
console.log(eachRes.length); | ||
eachRes.map(function(obj) { | ||
let tempDataObj = {}; | ||
for (let i in keys) { | ||
if (obj[keys[i].fieldName] && Array.isArray(obj[keys[i].fieldName])) { | ||
tempDataObj[keys[i].fieldName] = obj[keys[i].fieldName].toString(); | ||
} else if (keys[i].dataType && (obj[keys[i].fieldName] == "" || obj[keys[i].fieldName] == null || obj[keys[i].fieldName] == undefined)) { | ||
tempDataObj[keys[i].fieldName] = ""; | ||
} else if(keys[i].dataType) { | ||
tempDataObj[keys[i].fieldName] = obj[keys[i].fieldName]; | ||
} | ||
if(Object.keys(obj).length > 0) { | ||
for (let i in keys) { | ||
if(keys[i].dataType === 'agDateColumnFilter') { | ||
const dateVal = obj[keys[i].fieldName] ? new Date(obj[keys[i].fieldName]) : null; | ||
if(dateVal) { | ||
tempDataObj[keys[i].fieldName] = moment(dateVal).format("DD/MM/YYYY"); | ||
if (obj[keys[i].fieldName] && Array.isArray(obj[keys[i].fieldName])) { | ||
tempDataObj[keys[i].fieldName] = obj[keys[i].fieldName].toString(); | ||
} else if (keys[i].dataType && (obj[keys[i].fieldName] == "" || obj[keys[i].fieldName] == null || obj[keys[i].fieldName] == undefined)) { | ||
tempDataObj[keys[i].fieldName] = ""; | ||
} else if(keys[i].fieldName) { | ||
tempDataObj[keys[i].fieldName] = obj[keys[i].fieldName]; | ||
} else { | ||
console.log('-----------key value not found in each resposne'); | ||
console.log(JSON.stringify(obj)); | ||
tempDataObj[keys[i].fieldName] = ""; | ||
} | ||
if(keys[i].dataType === 'agDateColumnFilter') { | ||
const dateVal = obj[keys[i].fieldName] ? new Date(obj[keys[i].fieldName]) : null; | ||
if(dateVal) { | ||
tempDataObj[keys[i].fieldName] = moment(dateVal).format("DD/MM/YYYY"); | ||
} | ||
} | ||
} | ||
} | ||
flagValue.map(eachVal => { | ||
let match = false; | ||
flagColumns.some(flagCol => { | ||
const typeOfVal = typeof(obj[flagCol.field]); | ||
match = checkFlagCondition(typeOfVal, eachVal, obj[flagCol.field]); | ||
if(match) return match | ||
}); | ||
tempDataObj[`Keyword - ${eachVal}`] = match ? '1' : '0'; | ||
}) | ||
flagValue.map(eachVal => { | ||
let match = false; | ||
flagColumns.some(flagCol => { | ||
const typeOfVal = typeof(obj[flagCol.field]); | ||
match = checkFlagCondition(typeOfVal, eachVal, obj[flagCol.field]); | ||
if(match) return match | ||
}); | ||
tempDataObj[`Keyword - ${eachVal}`] = match ? '1' : '0'; | ||
}) | ||
} else { | ||
console.log('------------No key found in each resposne obj'); | ||
} | ||
finalExportResultArray.push(tempDataObj); | ||
@@ -1021,2 +1038,5 @@ }); | ||
console.log('---------------Export Batch Query'); | ||
console.log(JSON.stringify(query)); | ||
return await query.exec().then((results) => { | ||
@@ -1023,0 +1043,0 @@ return results; |
45040
943