I have a relation mapping in a Objection.js model and I need to set a filter on a field, but this field must be filtered by 2 possible values null or 0.
This is an example of relation like one i use:
static get relationMappings() {
return {
dipendenti: {
relation: Model.ManyToManyRelation,
modelClass: path.join(__dirname, '/DestModel'),
filter: {
[`field1`]: [null],
},
join: {
from: `fromField`,
through: {
modelClass: path.join(__dirname, '/ThroughModel'),
from: `throughFromField`,
to: `throughToField`
},
to: `toField`
}
}
};
}
I tried these two methods, but neither works:
filter: {
[`field1`]: [null, 0],
},
filter: {
[`field1`]: [null],
[`field1`]: [0],
},
Somebody know the right way for filter a field by 2 values using Objection.js?