perspectives - remove mongo hardcodes

This commit is contained in:
Jan Prochazka
2024-08-20 10:28:02 +02:00
parent 30e3bc6eeb
commit 80a4d3f238
10 changed files with 133 additions and 149 deletions

View File

@@ -7,7 +7,7 @@ const MongoClient = require('mongodb').MongoClient;
const ObjectId = require('mongodb').ObjectId;
const AbstractCursor = require('mongodb').AbstractCursor;
const createBulkInsertStream = require('./createBulkInsertStream');
const { convertToMongoCondition } = require('../frontend/convertToMongoCondition');
const { convertToMongoCondition, convertToMongoAggregate } = require('../frontend/convertToMongoCondition');
function transformMongoData(row) {
return _.cloneDeepWith(row, (x) => {
@@ -280,7 +280,7 @@ const driver = {
const count = await collection.countDocuments(convertObjectId(mongoCondition) || {});
return { count };
} else if (options.aggregate) {
let cursor = await collection.aggregate(convertObjectId(options.aggregate));
let cursor = await collection.aggregate(convertObjectId(convertToMongoAggregate(options.aggregate)));
const rows = await cursor.toArray();
return { rows: rows.map(transformMongoData) };
} else {