diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index 5f1f1fec7da52bd97fd2e3f4c0091186d2123c01..2ae465e1554349495ec2cb7ae3ebea274c3ca04a 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -188,13 +188,26 @@ export class StructuresService { * @return [{id: 'key', count: 'value'}] */ public async countByStructureKey(key: string): Promise<any> { + console.log('key is:', key); const uniqueElements = await this.structureModel.distinct(key).exec(); + console.log('unique elements:', uniqueElements); return await Promise.all( uniqueElements.map(async (value) => { return { id: value, count: await this.structureModel - .countDocuments({ $and: [{ [key]: { $elemMatch: { $eq: value } }, deletedAt: { $exists: false } }] }) + .countDocuments({ + $and: [ + { + [key]: { $elemMatch: { $eq: value } }, + //['proceduresAccompaniment']: { $elemMatch: { $eq: 'accompagnantCaf' } }, + deletedAt: { $exists: false }, + }, + { + // ['proceduresAccompaniment']: { $elemMatch: { $eq: 'accompagnantCaf' } }, + }, + ], + }) .exec(), }; })