add createMany fields to fieldMetadataService to batch field creation (#9957)
## Context Not exposed in the API yet, this new method allows us to reduce the time to create multiple fields at once, mostly during seeding. This allows us to batch transactions and avoid recomputing the cache everytime. With this change, we recompute the cache 7 times instead of 35 during seeding. We could do the same for objects.
This commit is contained in:
@ -265,13 +265,12 @@ export class DataSeedWorkspaceCommand extends CommandRunner {
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
for (const customField of DEV_SEED_COMPANY_CUSTOM_FIELDS) {
|
||||
// TODO: Use createMany once implemented for better performances
|
||||
await this.fieldMetadataService.createOne({
|
||||
await this.fieldMetadataService.createMany(
|
||||
DEV_SEED_COMPANY_CUSTOM_FIELDS.map((customField) => ({
|
||||
...customField,
|
||||
isCustom: true,
|
||||
});
|
||||
}
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
async seedPeopleCustomFields(
|
||||
@ -289,11 +288,11 @@ export class DataSeedWorkspaceCommand extends CommandRunner {
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
for (const customField of DEV_SEED_PERSON_CUSTOM_FIELDS) {
|
||||
await this.fieldMetadataService.createOne({
|
||||
await this.fieldMetadataService.createMany(
|
||||
DEV_SEED_PERSON_CUSTOM_FIELDS.map((customField) => ({
|
||||
...customField,
|
||||
isCustom: true,
|
||||
});
|
||||
}
|
||||
})),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user