0

I am having trouble connecting relationships in sequelize.

SELECT * from actors 
JOIN "actorStatuses" 
   on "actorStatuses".actor_id = actors.id 
JOIN movies 
   on movies.id = "actorStatuses".actor_id 
WHERE movies.date = '7/8/2017';

1 Answer 1

1

Here you go :

model.Actor.findAll({ // change model name as per yours
    include : [
        {
            model : model.ActorStatuses // change model name as per yours
            required : true ,
        },{
            model : model.Movies // change model name as per yours
            required : true ,
            where : { date : 'your_date' }
        }
    ]
});

This will create exact same query / result as you required.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for responding, but don't I see to define the relationships first?
Yes that's the obvious thing
Thank you so much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.