Ignore '_metadata', convert 'map' to Object

Legacy Parse platform databases have additional fields that
database-to-api-response conversion. This commit accounts for

- the '_metadata' field, which doesn't appear in the api-response version
  of Schema, and whose value (an object), crashes the conversion function
  (which expects only string values)
- the 'map' type, which appears in legacy database representations to
  describe Objects
This commit is contained in:
Eric Watson
2016-02-04 11:39:11 -06:00
parent c106ac6499
commit fdc85cc5c2

View File

@@ -23,6 +23,7 @@ function mongoFieldTypeToApiResponseType(type) {
case 'string': return {type: 'String'};
case 'boolean': return {type: 'Boolean'};
case 'date': return {type: 'Date'};
case 'map':
case 'object': return {type: 'Object'};
case 'array': return {type: 'Array'};
case 'geopoint': return {type: 'GeoPoint'};
@@ -31,7 +32,7 @@ function mongoFieldTypeToApiResponseType(type) {
}
function mongoSchemaAPIResponseFields(schema) {
fieldNames = Object.keys(schema).filter(key => key !== '_id');
fieldNames = Object.keys(schema).filter(key => key !== '_id' && key !== '_metadata');
response = {};
fieldNames.forEach(fieldName => {
response[fieldName] = mongoFieldTypeToApiResponseType(schema[fieldName]);