Linked Questions

Popular Questions

Setting up a Sequelize.js association with an OR condition

Asked by At

I have two Sequelize models that look like:

User = sequelize.define('User', { id: ... });
Connection = sequelize.define('Connection', {
    mentor_id: ...,
    mentee_id: ...
});

Where mentor_id and mentee_id are references to a User.

I would like to set up an association to get all the Connections associated with a user, based on if the user is a mentor OR mentee.

I know how to set up basic associations, but wasn't sure how to go about adding in this OR condition. Is it possible?

Related Questions