Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/special_filters/IsReferencedByResourcesMatching.js
Show All 22 Lines | class IsReferencedByResourcesMatching extends app.SpecialFilter { | ||||
assert(Array.isArray(allowed_values)); | assert(Array.isArray(allowed_values)); | ||||
assert(typeof nopass_reason === "string"); | assert(typeof nopass_reason === "string"); | ||||
} | } | ||||
async getFilteringQuery() { | async getFilteringQuery() { | ||||
const query = new Query(); | const query = new Query(); | ||||
const lookup_id = query.lookup({ | const lookup_id = query.lookup({ | ||||
from: this.params.collection.name, | from: this.params.collection.name, | ||||
localField: "sealious_id", | localField: "sealious_id", | ||||
foreignField: `body.${this.params.referencing_field}`, | foreignField: this.params.referencing_field, | ||||
}); | }); | ||||
query.match({ | query.match({ | ||||
[`${lookup_id}.body.${this.params.field_to_check}`]: { | [`${lookup_id}.${this.params.field_to_check}`]: { | ||||
$in: this.params.allowed_values, | $in: this.params.allowed_values, | ||||
}, | }, | ||||
}); | }); | ||||
return query; | return query; | ||||
} | } | ||||
getNopassReason() { | getNopassReason() { | ||||
return this.params.nopass_reason; | return this.params.nopass_reason; | ||||
} | } | ||||
} | } | ||||
); | ); | ||||
app.SpecialFilter.IsReferencedByResourcesMatching = parametrized; | app.SpecialFilter.IsReferencedByResourcesMatching = parametrized; | ||||
}; | }; |