Skip to content

Commit

Permalink
updates to use the correct model in case it is not the default Revisi…
Browse files Browse the repository at this point in the history
…on model name
  • Loading branch information
nielsgl committed May 2, 2016
1 parent e9e114d commit 66d1bff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default (sequelize: sequelize, options: object): object => {
this.addHook("afterUpdate", afterHook);

// create association
this.hasMany(sequelize.models.Revision, {
this.hasMany(sequelize.models[options.revisionModel], {
foreignKey: "document_id",
constraints: false,
scope: {
Expand Down Expand Up @@ -291,7 +291,7 @@ export default (sequelize: sequelize, options: object): object => {
d.save()
.then(function(d: any){
// Add diff to revision
revision.addRevisionChange(d);
revision['add' + options.revisionChangeModel](d);
return null;
})
.catch((err: any) => {
Expand Down Expand Up @@ -377,6 +377,7 @@ export default (sequelize: sequelize, options: object): object => {
var RevisionChange = sequelize.define(options.revisionChangeModel, attributes, {
underscored: options.underscored
});

// Set associations
Revision.hasMany(RevisionChange, {
foreignKey: options.defaultAttributes.revisionId,
Expand Down

0 comments on commit 66d1bff

Please sign in to comment.