diff --git a/lib/dao.js b/lib/dao.js index 267d609e..671d4a00 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -1,3 +1,4 @@ + /*! * Module exports class Model */ diff --git a/lib/model.js b/lib/model.js index 3a3b3999..ba1a1e87 100644 --- a/lib/model.js +++ b/lib/model.js @@ -242,10 +242,13 @@ ModelBaseClass.prototype.toObject = function (onlySchema, removeHidden) { var self = this; var Model = this.constructor; + // if it is already an Object + if(Model === Object) return self; + var strict = this.__strict; var schemaLess = (strict === false) || !onlySchema; - this.constructor.forEachProperty(function (propertyName) { + Model.forEachProperty(function (propertyName) { if(removeHidden && Model.isHiddenProperty(propertyName)) return; if (self[propertyName] instanceof List) { data[propertyName] = self[propertyName].toObject(!schemaLess, removeHidden);