From fdc85cc5c2ff20e5fd249f12866cd21c69490b7d Mon Sep 17 00:00:00 2001 From: Eric Watson Date: Thu, 4 Feb 2016 11:39:11 -0600 Subject: [PATCH] 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 --- schemas.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/schemas.js b/schemas.js index 88b0da38fe..9b74f2702d 100644 --- a/schemas.js +++ b/schemas.js @@ -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]);