Skip to content

Commit

Permalink
fix: _projection fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MXPOL committed Dec 4, 2023
1 parent ea31cdb commit 32bf65b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/velo-external-db-core/src/service/schema_aware_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 32bf65b

Please sign in to comment.