This should do it:
// api/models/Genres.js module.exports = { attributes : { name : { type: 'string' }, slug : { type: 'string' }, type : { type: 'string' }, radios : { collection: 'Radios', through: 'genres_radios' } } } // api/models/Radios.js module.exports = { attributes : { name : { type: 'string' }, slug : { type: 'string' }, url : { type: 'string' }, genres : { collection: 'genre', through: 'genres_radios' } } } // api/models/Genres_radios.js module.exports = { attributes = { 'Genre_id': { columnName:'genre_id', type:'integer', foreignKey:'true', references:'genres', on:'id', via:'genres' }, 'Radio_id': { columnName:'radio_id', type:'integer', foreignKey:'true', references:'radios', on:'id', via:'radios' } } }
And then you can make the following request:
Radio.findOne({name:"RadioName"}).populate("genres").then(function(radio){ console.log(radio); })
source share