diff --git a/lib/model-builder.js b/lib/model-builder.js index 0d49dd7a..af8f2bcb 100644 --- a/lib/model-builder.js +++ b/lib/model-builder.js @@ -140,7 +140,7 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett // every class can receive hash of data as optional param ModelClass = function ModelConstructor(data, dataSource) { if(!(this instanceof ModelConstructor)) { - return new ModelConstructor(data, modelBuilder); + return new ModelConstructor(data, dataSource); } if(ModelClass.settings.unresolved) { throw new Error('Model ' + ModelClass.modelName + ' is not defined.'); @@ -172,6 +172,7 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett // Add metadata to the ModelClass hiddenProperty(ModelClass, 'modelBuilder', modelBuilder); + hiddenProperty(ModelClass, 'dataSource', modelBuilder); // Keep for back-compatibility hiddenProperty(ModelClass, 'pluralModelName', pluralName || inflection.pluralize(className)); hiddenProperty(ModelClass, 'relations', {});