0
In my Proposal table I have two Foreign Keys that reference the same table(Producer), I need to make a Where to check if there is a producer with a document equal to the searched in one of these Foreign Keys
Example:
Proposta -> id| nome_proposta | valor | produtor1 | produtor2 |
0| proposta vida | 12.00 | 0 | 1 |
Produtor1 -> id| nome |documento
0| João | 12543
Produtor2 -> id| nome |documento
1| Lucas| 85476
Follow the Sequelize part:
where: {
[Op.or]: {
{
model: Produtor,
as: "produtor1",
where: {
documento : documento_produtor,
},
},
{
model: Produtor,
as: "produtor2",
where: {
documento : documento_produtor,
},
},
}
}
Is there any way to perform this Select that would return the two producers of that proposal but only one had the same document? Why in my test I can only research one at a time.
Note: I have no way of knowing if the producer I want ta in the first or second Foreign key
I didn’t get it right. You want the
Op.or
function as "or exclusive" (xor)?– Rafael Tavares
@Rafaeltavares It would be exclusive anyway, because document is a unique value. The point is that this OR does not work. And I don’t know how to do this OR with include
– Bruno Santi