Skip to content
Snippets Groups Projects
Commit a1568197 authored by Antonin COQUET's avatar Antonin COQUET
Browse files

feat: edit request for structure service (not working)

parent 09bbe45a
3 merge requests!96release V1.10.0,!62Dev,!58Feat/structure filter
......@@ -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(),
};
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment