diff --git a/lib/Associations/Extend.js b/lib/Associations/Extend.js index 36357f0f..e02f7fdc 100644 --- a/lib/Associations/Extend.js +++ b/lib/Associations/Extend.js @@ -108,6 +108,10 @@ function extendInstance(Model, Instance, Driver, association, opts) { var fields = Object.keys(association.field); + if (!Extension.isInstance) { + Extension = new association.model(Extension); + } + for (var i = 0; i < Model.id.length; i++) { Extension[fields[i]] = Instance[Model.id[i]]; } diff --git a/lib/Instance.js b/lib/Instance.js index d7557b4f..c9714221 100755 --- a/lib/Instance.js +++ b/lib/Instance.js @@ -123,6 +123,7 @@ function Instance(Model, opts) { }; var afterSave = function (cb, create, err) { emitEvent("save", err, instance); + if (create) { Hook.trigger(instance, opts.hooks.afterCreate, !err); }