From 32bf65b6e0114ce8c3dae12468025a7f59758650 Mon Sep 17 00:00:00 2001 From: Max Polsky Date: Mon, 4 Dec 2023 17:49:37 +0200 Subject: [PATCH] fix: _projection fix --- libs/velo-external-db-core/src/service/schema_aware_data.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/velo-external-db-core/src/service/schema_aware_data.ts b/libs/velo-external-db-core/src/service/schema_aware_data.ts index 2c41c06be..679cd37b6 100644 --- a/libs/velo-external-db-core/src/service/schema_aware_data.ts +++ b/libs/velo-external-db-core/src/service/schema_aware_data.ts @@ -123,10 +123,10 @@ export default class SchemaAwareDataService { return fields.map((f: { field: any }) => f.field) } - private async projectionFor(collectionName: string, _projection?: string[]) { + private async projectionFor(collectionName: string, _projection = [] as string[]) { const schemaFields = await this.schemaInformation.schemaFieldsFor(collectionName) const schemaContainsId = schemaFields.some(f => f.field === '_id') - const projection = (_projection && _projection.length === 0) ? schemaFields.map(f => f.field) : _projection as string[] + const projection = _projection.length === 0 ? schemaFields.map(f => f.field) : _projection as string[] return schemaContainsId ? Array.from(new Set(['_id', ...projection])) : projection } }