Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsgl committed May 2, 2016
2 parents 742edf2 + 77da7e7 commit e738bd6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ exports.default = function (sequelize, options) {
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 @@ -286,7 +286,7 @@ exports.default = function (sequelize, options) {

d.save().then(function (d) {
// Add diff to revision
revision.addRevisionChange(d);
revision['add' + options.revisionChangeModel](d);
return null;
}).catch(function (err) {
log('RevisionChange save error');
Expand Down Expand Up @@ -372,6 +372,7 @@ exports.default = function (sequelize, options) {
var RevisionChange = sequelize.define(options.revisionChangeModel, attributes, {
underscored: options.underscored
});

// Set associations
Revision.hasMany(RevisionChange, {
foreignKey: options.defaultAttributes.revisionId,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sequelize-paper-trail",
"version": "0.4.0",
"version": "1.0.0",
"description": "Track changes to your Sequelize models data. Perfect for auditing or versioning.",
"bugs": {
"url": "https://github.com/nielsgl/sequelize-paper-trail/issues",
Expand Down
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 e738bd6

Please sign in to comment.