1
1
import log from './logger' ;
2
+ import _ from 'lodash' ;
2
3
var mongodb = require ( 'mongodb' ) ;
3
4
var Parse = require ( 'parse/node' ) . Parse ;
4
5
@@ -149,8 +150,6 @@ export function transformKeyValue(schema, className, restKey, restValue, options
149
150
throw 'There was a problem transforming an ACL.' ;
150
151
}
151
152
152
-
153
-
154
153
// Handle arrays
155
154
if ( restValue instanceof Array ) {
156
155
if ( options . query ) {
@@ -613,6 +612,21 @@ function transformUpdateOperator(operator, flatten) {
613
612
}
614
613
}
615
614
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
+ ] ;
616
630
617
631
// Converts from a mongo-format object to a REST-format object.
618
632
// Does not strip out anything based on a lack of authentication.
@@ -630,10 +644,9 @@ function untransformObject(schema, className, mongoObject, isNestedObject = fals
630
644
if ( mongoObject === null ) {
631
645
return null ;
632
646
}
633
-
634
647
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 ) ;
637
650
} ) ;
638
651
}
639
652
@@ -647,6 +660,10 @@ function untransformObject(schema, className, mongoObject, isNestedObject = fals
647
660
648
661
var restObject = untransformACL ( mongoObject ) ;
649
662
for ( var key in mongoObject ) {
663
+ if ( isNestedObject && _ . includes ( specialKeysForUntransform , key ) ) {
664
+ restObject [ key ] = untransformObject ( schema , className , mongoObject [ key ] , true ) ;
665
+ continue ;
666
+ }
650
667
switch ( key ) {
651
668
case '_id' :
652
669
restObject [ 'objectId' ] = '' + mongoObject [ key ] ;
@@ -728,8 +745,7 @@ function untransformObject(schema, className, mongoObject, isNestedObject = fals
728
745
break ;
729
746
}
730
747
}
731
- restObject [ key ] = untransformObject ( schema , className ,
732
- mongoObject [ key ] , true ) ;
748
+ restObject [ key ] = untransformObject ( schema , className , mongoObject [ key ] , true ) ;
733
749
}
734
750
}
735
751
0 commit comments