Removing the need for schema/collection on temp tools when deleting it

This commit is contained in:
Bruno Alves de Faria 2017-09-05 21:22:39 -03:00
parent 861931b329
commit 3a36c89fd4

View File

@ -10,7 +10,7 @@ class MeasurementHandlers {
const measurementData = eventData.measurementData;
const Collection = measurementApi.tools[eventData.toolType];
// Stop here if the tool data shall not be stored (e.g. temp tools)
// Stop here if the tool data shall not be persisted (e.g. temp tools)
if (!Collection) {
return;
}
@ -79,7 +79,7 @@ class MeasurementHandlers {
const measurementData = eventData.measurementData;
const Collection = measurementApi.tools[eventData.toolType];
// Stop here if the tool data shall not be stored (e.g. temp tools)
// Stop here if the tool data shall not be persisted (e.g. temp tools)
if (!Collection) {
return;
}
@ -121,9 +121,15 @@ class MeasurementHandlers {
const measurementData = eventData.measurementData;
const measurementNumber = measurementData.measurementNumber;
const { measurementApi, timepointApi } = instance.data;
const collection = measurementApi.tools[eventData.toolType];
const Collection = measurementApi.tools[eventData.toolType];
// Stop here if the tool data shall not be persisted (e.g. temp tools)
if (!Collection) {
return;
}
const measurementTypeId = measurementApi.toolsGroupsMap[measurementData.toolType];
const measurement = collection.findOne(measurementData._id);
const measurement = Collection.findOne(measurementData._id);
const timepointId = measurement.timepointId;
// Remove all the measurements with the given type and number