Remove getRelationFields

This commit is contained in:
Drew Gross
2016-05-23 17:01:47 -07:00
parent f4b1f7b951
commit e440046be4
3 changed files with 17 additions and 28 deletions

View File

@@ -868,7 +868,16 @@ const mongoObjectToParseObject = (schemaController, className, mongoObject, sche
}
}
return { ...restObject, ...schemaController.getRelationFields(className) };
const relationFieldNames = Object.keys(schema.fields).filter(fieldName => schema.fields[fieldName].type === 'Relation');
let relationFields = {};
relationFieldNames.forEach(relationFieldName => {
relationFields[relationFieldName] = {
__type: 'Relation',
className: schema.fields[relationFieldName].targetClass,
}
});
return { ...restObject, ...relationFields };
default:
throw 'unknown js type';
}

View File

@@ -686,23 +686,6 @@ class SchemaController {
hasClass(className) {
return this.reloadData().then(() => !!(this.data[className]));
}
getRelationFields(className) {
if (this.data && this.data[className]) {
let classData = this.data[className];
return Object.keys(classData).filter((field) => {
return classData[field].type === 'Relation';
}).reduce((memo, field) => {
let type = classData[field];
memo[field] = {
__type: 'Relation',
className: type.targetClass
};
return memo;
}, {});
}
return {};
}
}
// Returns a promise for a new Schema.