fixed measurements lookup pipeline
This commit is contained in:
parent
fd5c0d2c74
commit
37a5ba1bfd
@ -230,8 +230,11 @@ router.get('/samples', async (req, res, next) => {
|
|||||||
{$eq: ['$sample_id', '$$sId']},
|
{$eq: ['$sample_id', '$$sId']},
|
||||||
{$in: ['$measurement_template', measurementTemplates.map(e => mongoose.Types.ObjectId(e._id))]}
|
{$in: ['$measurement_template', measurementTemplates.map(e => mongoose.Types.ObjectId(e._id))]}
|
||||||
]}}},
|
]}}},
|
||||||
{$project: filters.fields.filter(e => /measurements\./.test(e))
|
{$project: _.merge(
|
||||||
.map(e => 'values.' + e.replace('measurements.', '')).reduce((s, e) => {s[e] = true; return s; }, {})}
|
filters.fields.filter(e => /measurements\./.test(e))
|
||||||
|
.map(e => 'values.' + e.split('.')[2]).reduce((s, e) => {s[e] = true; return s; }, {}),
|
||||||
|
{measurement_template: true, status: true, sample_id: true}
|
||||||
|
)}
|
||||||
],
|
],
|
||||||
as: 'measurements'
|
as: 'measurements'
|
||||||
}});
|
}});
|
||||||
@ -328,8 +331,11 @@ router.get('/samples', async (req, res, next) => {
|
|||||||
{$eq: ['$sample_id', '$$sId']},
|
{$eq: ['$sample_id', '$$sId']},
|
||||||
{$in: ['$measurement_template', measurementTemplates.map(e => mongoose.Types.ObjectId(e._id))]}
|
{$in: ['$measurement_template', measurementTemplates.map(e => mongoose.Types.ObjectId(e._id))]}
|
||||||
]}}},
|
]}}},
|
||||||
{$project: filters.fields.filter(e => /measurements\./.test(e))
|
{$project: _.merge(
|
||||||
.map(e => 'values.' + e.replace('measurements.', '')).reduce((s, e) => {s[e] = true; return s; }, {})}
|
filters.fields.filter(e => /measurements\./.test(e))
|
||||||
|
.map(e => 'values.' + e.split('.')[2]).reduce((s, e) => {s[e] = true; return s; }, {}),
|
||||||
|
{measurement_template: true, status: true, sample_id: true}
|
||||||
|
)}
|
||||||
],
|
],
|
||||||
as: 'measurements'
|
as: 'measurements'
|
||||||
}});
|
}});
|
||||||
|
Reference in New Issue
Block a user