Q:

How to translate mysql query to sequelize

I need to perform this query with sequelize:
SELECT movie, genre FROM `yt_movies` M 
LEFT JOIN `genres_link` GL ON M.id = GL.movie_id
WHERE M.id = 1098

I tried 
const YtMovies = db.yt_movies;
const Genres = db.genres;
const GenresLink = db.genres_link;

YtMovies.hasMany(GenresLink, { as: 'GL' });
YtMovies.hasMany(Genres, { as: 'G' });

const res = await db.yt_movies.findAll({
    attributes: ['movie'],
    where: { id: movie_id },
    include: [
        {
            model: db.genres_link,
            as: 'GL',
            required: false,
            // where: { movie_id },
            attributes: ['genre_id'],
        },

    ],
}

but it returns
SELECT
`yt_movies`.`id`,
`yt_movies`.`movie`,
`GL`.`id` AS `GL.id`,
`GL`.`genre_id` AS `GL.genre_id`
FROM `yt_movies` AS `yt_movies`
LEFT OUTER JOIN `genres_link` AS `GL` 
ON `yt_movies`.`id` = `GL`.`yt_movie_id` WHERE `yt_movies`.`id` = 1098;

the last string two lines are incorrect, I expect movie_id instead of yt_movie_id. There is no columns with yt_movie_id name in project
LEFT JOIN `genres_link` GL
ON `yt_movies`.id = `GL`.`movie_id` WHERE `yt_movies`.`id` = 1098;

Please HALP 
Thanks!

A:

You need to provide the sourceKey and foreignKey options, if you want to use specific columns to make association.
Try this one:
YtMovies.hasMany(GenresLink, { as: 'GL' , foreignKey: 'movie_id'})

