feat(MongoDB Node): Add projection to query options on Find (#9972)

Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
This commit is contained in:
Mickaël Andrieu
2024-08-07 11:39:44 +02:00
committed by GitHub
parent c5acbb7ec0
commit 0a84e0d8b0
2 changed files with 19 additions and 1 deletions

View File

@@ -196,6 +196,8 @@ export class MongoDb implements INodeType {
const options = this.getNodeParameter('options', i);
const limit = options.limit as number;
const skip = options.skip as number;
const projection =
options.projection && (JSON.parse(options.projection as string) as Document);
const sort = options.sort && (JSON.parse(options.sort as string) as Sort);
if (skip > 0) {
@@ -208,6 +210,10 @@ export class MongoDb implements INodeType {
query = query.sort(sort);
}
if (projection && projection instanceof Document) {
query = query.project(projection);
}
const queryResult = await query.toArray();
for (const entry of queryResult) {