I have 2 Models that are related through hasAndBelongsToMany
Releationship through 3 intermediate model. eg. Artist
is related to Tracklist
model through third intermediate model TracklistArtist
. Tracklist model have belongsTo with Song
model.
I want to fetch song related with the particular artist.
Artist.tracklists({
id: $stateParams.artistId,
filter: {
include: [{relation:"song",scope:{limit:2}}]
}
}).$promise.then(function (data) {
$scope.items = data;
});
I am referring link to filter the include condition from this link. IncludeFilter
Issue is --
- its not limiting the relational data of song. I am applying pagination so I want limited data of song Model.
- I wish to find unique song. How to implement distinct to song model.