Do not .toObject if already Object
This commit is contained in:
parent
9b9833df0f
commit
4049f7338e
|
@ -1,3 +1,4 @@
|
|||
|
||||
/*!
|
||||
* Module exports class Model
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue