Remove getRelationFields
This commit is contained in:
@@ -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';
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user