Reputation: 31
I'm trying to search for the following condition in a merged table between two tables.
It should collect and return records that has the buyer 'alex'
or seller 'alex'
.
The buyer exists in Chat
table and seller exists in Market
table which I have included as shown below. However, I am unable to get it to work. Any ideas are welcome.
Chat.findAll({
where: {
buyer: 'alex',
seller: 'alex'
},
include: [{
model: Market,
required: true
}]
})
Upvotes: 0
Views: 559
Reputation: 7282
The seller
has to be inside Market
Chat.findAll({
where: {
buyer: 'alex',
},
include: [{
model: Market,
required: true,
where: {
seller: 'alex'
}
}]
})
Upvotes: 1