perspectives: support nosql other than mongo

This commit is contained in:
SPRINX0\prochazka
2024-08-28 15:49:32 +02:00
parent 73ec42a9c8
commit d243af323e
3 changed files with 14 additions and 5 deletions

View File

@@ -305,7 +305,12 @@ const driver = {
} else if (options.aggregate) {
let cursor = await collection.aggregate(convertObjectId(convertToMongoAggregate(options.aggregate)));
const rows = await cursor.toArray();
return { rows: rows.map(transformMongoData) };
return {
rows: rows.map(transformMongoData).map((x) => ({
...x._id,
..._.omit(x, ['_id']),
})),
};
} else {
// console.log('options.condition', JSON.stringify(options.condition, undefined, 2));
let cursor = await collection.find(convertObjectId(mongoCondition) || {});
@@ -313,7 +318,9 @@ const driver = {
if (options.skip) cursor = cursor.skip(options.skip);
if (options.limit) cursor = cursor.limit(options.limit);
const rows = await cursor.toArray();
return { rows: rows.map(transformMongoData) };
return {
rows: rows.map(transformMongoData),
};
}
} catch (err) {
return { errorMessage: err.message };