Do not .toObject if already Object
This commit is contained in:
parent
cf75f55f73
commit
0866a55cb2
|
@ -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