I have has many relation of 2 models via third through model in Loopback. My models are :
- Song
- Album
- Tracklist (- Thorough Model having songId & albumId as field.)
How would I make request in Song model for relating album with it? What I have tried is -
$scope.tagAdded = function () {
Song.albums.link({id: $scope.songId, fk: $scope.albumId},
{albumId: $scope.albumId, songId: $scope.songId})
.$promise
.then(function (value) {
console.log(value);
}, function (reason) {
});
};
Relations are proper. But its not adding data, at same time I wish if instance is already saved means relation is already made it won't save it. Don't create duplicate records.