Fix problems with _keys in nested objects

This commit is contained in:
Florent Vilmart
2016-02-20 09:45:09 -05:00
parent eb0340585f
commit fbdd89c2d1
2 changed files with 32 additions and 5 deletions

View File

@@ -586,7 +586,7 @@ function transformUpdateOperator(operator, flatten) {
// Converts from a mongo-format object to a REST-format object.
// Does not strip out anything based on a lack of authentication.
function untransformObject(schema, className, mongoObject) {
function untransformObject(schema, className, mongoObject, isNestedObject = false) {
switch(typeof mongoObject) {
case 'string':
case 'number':
@@ -683,10 +683,8 @@ function untransformObject(schema, className, mongoObject) {
objectId: objData[1]
};
break;
} else if (key[0] == '_' && key != '__type') {
} else if (!isNestedObject && key[0] == '_' && key != '__type') {
throw ('bad key in untransform: ' + key);
//} else if (mongoObject[key] === null) {
//break;
} else {
var expectedType = schema.getExpectedType(className, key);
var value = mongoObject[key];
@@ -700,7 +698,7 @@ function untransformObject(schema, className, mongoObject) {
}
}
restObject[key] = untransformObject(schema, className,
mongoObject[key]);
mongoObject[key], true);
}
}
return restObject;