feat: add user-defined schema and migrations (#7418)
This commit is contained in:
committed by
GitHub
parent
653d25731f
commit
25d5c30be2
@@ -212,7 +212,7 @@ class MongoSchemaCollection {
|
||||
.then(
|
||||
schema => {
|
||||
// If a field with this name already exists, it will be handled elsewhere.
|
||||
if (schema.fields[fieldName] != undefined) {
|
||||
if (schema.fields[fieldName] !== undefined) {
|
||||
return;
|
||||
}
|
||||
// The schema exists. Check for existing GeoPoints.
|
||||
@@ -274,6 +274,22 @@ class MongoSchemaCollection {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async updateFieldOptions(className: string, fieldName: string, fieldType: any) {
|
||||
const { ...fieldOptions } = fieldType;
|
||||
delete fieldOptions.type;
|
||||
delete fieldOptions.targetClass;
|
||||
|
||||
await this.upsertSchema(
|
||||
className,
|
||||
{ [fieldName]: { $exists: true } },
|
||||
{
|
||||
$set: {
|
||||
[`_metadata.fields_options.${fieldName}`]: fieldOptions,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Exported for testing reasons and because we haven't moved all mongo schema format
|
||||
|
||||
Reference in New Issue
Block a user