Minor tweaks; pass-through properties/scope for hasAndBelongsToMany

This commit is contained in:
Fabien Franzen 2014-07-26 21:32:24 +02:00
parent 5e30ec8637
commit 5a5aa3f14d
2 changed files with 3 additions and 0 deletions

View File

@ -1084,6 +1084,8 @@ RelationDefinition.hasAndBelongsToMany = function hasAndBelongsToMany(modelFrom,
}
var options = {as: params.as, through: params.through};
options.properties = params.properties;
options.scope = params.scope;
if (isPolymorphic) {
options.polymorphic = params.polymorphic;

View File

@ -788,6 +788,7 @@ describe('relations', function () {
it('can be declared', function (done) {
Author.hasAndBelongsToMany(Picture, { through: PictureLink, polymorphic: 'imageable' });
Reader.hasAndBelongsToMany(Picture, { through: PictureLink, polymorphic: 'imageable' });
// Optionally, define inverse relations:
Picture.hasMany(Author, { through: PictureLink, polymorphic: 'imageable', invert: true });
Picture.hasMany(Reader, { through: PictureLink, polymorphic: 'imageable', invert: true });
db.automigrate(done);