'Objectionjs: relation with multiple columns but some column could be null
I have a Model, using Objection JS, with this relation:
class Model....{
...
static relationMappings = {
...
evs:{
relation: Model.ManyToManyRelation,
modelClass: path.join(__dirname, 'evs-model'),
join: {
from: ['factura.factura_id', 'factura.uuid'],
through: {
from: ['_junction_evs.factura_id', '_junction_evs.uuid'],
to: '_junction_evs.evidencia_id',
extra: ['empresa_id', 'monto_pagado', 'monto_pesos']
},
to: 'evidencias_pagos.id',
}
}
}
}
the problem is: when the column uuid is null (used in the "from" join), the await Model.relatedQuery('evs').for(id)
returns empty array but I know is incorrect.
How could I do this relation?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|