11import log from './logger' ;
2+ import _ from 'lodash' ;
23var mongodb = require ( 'mongodb' ) ;
34var Parse = require ( 'parse/node' ) . Parse ;
45
@@ -149,8 +150,6 @@ export function transformKeyValue(schema, className, restKey, restValue, options
149150 throw 'There was a problem transforming an ACL.' ;
150151 }
151152
152-
153-
154153 // Handle arrays
155154 if ( restValue instanceof Array ) {
156155 if ( options . query ) {
@@ -613,6 +612,21 @@ function transformUpdateOperator(operator, flatten) {
613612 }
614613}
615614
615+ const specialKeysForUntransform = [
616+ '_id' ,
617+ '_hashed_password' ,
618+ '_acl' ,
619+ '_email_verify_token' ,
620+ '_perishable_token' ,
621+ '_tombstone' ,
622+ '_session_token' ,
623+ 'updatedAt' ,
624+ '_updated_at' ,
625+ 'createdAt' ,
626+ '_created_at' ,
627+ 'expiresAt' ,
628+ '_expiresAt' ,
629+ ] ;
616630
617631// Converts from a mongo-format object to a REST-format object.
618632// Does not strip out anything based on a lack of authentication.
@@ -630,10 +644,9 @@ function untransformObject(schema, className, mongoObject, isNestedObject = fals
630644 if ( mongoObject === null ) {
631645 return null ;
632646 }
633-
634647 if ( mongoObject instanceof Array ) {
635- return mongoObject . map ( ( o ) => {
636- return untransformObject ( schema , className , o , true ) ;
648+ return mongoObject . map ( arrayEntry => {
649+ return untransformObject ( schema , className , arrayEntry , true ) ;
637650 } ) ;
638651 }
639652
@@ -647,6 +660,10 @@ function untransformObject(schema, className, mongoObject, isNestedObject = fals
647660
648661 var restObject = untransformACL ( mongoObject ) ;
649662 for ( var key in mongoObject ) {
663+ if ( isNestedObject && _ . includes ( specialKeysForUntransform , key ) ) {
664+ restObject [ key ] = untransformObject ( schema , className , mongoObject [ key ] , true ) ;
665+ continue ;
666+ }
650667 switch ( key ) {
651668 case '_id' :
652669 restObject [ 'objectId' ] = '' + mongoObject [ key ] ;
@@ -728,8 +745,7 @@ function untransformObject(schema, className, mongoObject, isNestedObject = fals
728745 break ;
729746 }
730747 }
731- restObject [ key ] = untransformObject ( schema , className ,
732- mongoObject [ key ] , true ) ;
748+ restObject [ key ] = untransformObject ( schema , className , mongoObject [ key ] , true ) ;
733749 }
734750 }
735751
0 commit comments