Skip to content

Commit bea9c0b

Browse files
committed
Allows user to pass an object to extendsTo.setAccessor instead of an instance (detected via #250)
1 parent b888d9e commit bea9c0b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/Associations/Extend.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ function extendInstance(Model, Instance, Driver, association, opts) {
108108

109109
var fields = Object.keys(association.field);
110110

111+
if (!Extension.isInstance) {
112+
Extension = new association.model(Extension);
113+
}
114+
111115
for (var i = 0; i < Model.id.length; i++) {
112116
Extension[fields[i]] = Instance[Model.id[i]];
113117
}

lib/Instance.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function Instance(Model, opts) {
123123
};
124124
var afterSave = function (cb, create, err) {
125125
emitEvent("save", err, instance);
126+
126127
if (create) {
127128
Hook.trigger(instance, opts.hooks.afterCreate, !err);
128129
}

0 commit comments

Comments
 (0)