@loomcore/api 0.0.51 → 0.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -122,35 +122,25 @@ export class GenericApiService {
|
|
|
122
122
|
return pagedResult;
|
|
123
123
|
}
|
|
124
124
|
async getById(userContext, id) {
|
|
125
|
-
console.log(`--- GenericApiService.getById ENTER ---`);
|
|
126
|
-
console.log(`ID received: ${id}`);
|
|
127
125
|
if (!entityUtils.isValidObjectId(id)) {
|
|
128
126
|
throw new BadRequestError('id is not a valid ObjectId');
|
|
129
127
|
}
|
|
130
128
|
const baseQuery = { _id: new ObjectId(id) };
|
|
131
129
|
const query = this.prepareQuery(userContext, baseQuery);
|
|
132
|
-
console.log('Constructed query:', JSON.stringify(query, null, 2));
|
|
133
130
|
let entity = null;
|
|
134
131
|
if (this.getAdditionalPipelineStages().length > 0) {
|
|
135
|
-
console.log('Branch: Executing with aggregation pipeline.');
|
|
136
132
|
const pipeline = [
|
|
137
133
|
{ $match: query },
|
|
138
134
|
...this.getAdditionalPipelineStages()
|
|
139
135
|
];
|
|
140
|
-
console.log('Aggregation Pipeline:', JSON.stringify(pipeline, null, 2));
|
|
141
136
|
entity = await this.collection.aggregate(pipeline).next();
|
|
142
137
|
}
|
|
143
138
|
else {
|
|
144
|
-
console.log('Branch: Executing with findOne.');
|
|
145
139
|
entity = await this.collection.findOne(query);
|
|
146
140
|
}
|
|
147
|
-
console.log('IMMEDIATE DB RESULT (entity):', JSON.stringify(entity, null, 2));
|
|
148
141
|
if (!entity) {
|
|
149
|
-
console.log('Entity not found, throwing IdNotFoundError.');
|
|
150
142
|
throw new IdNotFoundError();
|
|
151
143
|
}
|
|
152
|
-
console.log('Entity before transformSingle:', JSON.stringify(entity, null, 2));
|
|
153
|
-
console.log(`--- GenericApiService.getById EXIT ---`);
|
|
154
144
|
return this.transformSingle(entity);
|
|
155
145
|
}
|
|
156
146
|
async getCount(userContext) {
|
|
@@ -371,14 +361,12 @@ export class GenericApiService {
|
|
|
371
361
|
return list.map(item => this.transformSingle(item));
|
|
372
362
|
}
|
|
373
363
|
transformSingle(single) {
|
|
374
|
-
console.log('Starting base class transformSingle, entity:', JSON.stringify(single, null, 2));
|
|
375
364
|
if (!single)
|
|
376
365
|
return single;
|
|
377
366
|
if (!this.modelSpec?.fullSchema) {
|
|
378
367
|
throw new ServerError(`Cannot transform entity: No model specification with schema provided for ${this.pluralResourceName}`);
|
|
379
368
|
}
|
|
380
369
|
const transformedEntity = dbUtils.convertObjectIdsToStrings(single, this.modelSpec.fullSchema);
|
|
381
|
-
console.log('Leaving base class transformSingle, transformedEntity:', JSON.stringify(transformedEntity, null, 2));
|
|
382
370
|
return transformedEntity;
|
|
383
371
|
}
|
|
384
372
|
stripSenderProvidedSystemProperties(userContext, doc, allowId = false) {
|