chore(product): revamp upsertWithReplace and Remove its usage from product creation (#11585)
**What** - Move create product to use native create by structuring the data appropriately, it means no more `upsertWithReplace` being very poorly performant and got 20x better performances on staging - Improvements in `upsertWithReplace` to still get performance boost for places that still relies on it. Mostly bulking the operations when possible Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a35c9ed741
commit
eeebb35758
@@ -283,14 +283,17 @@ export function defineHasManyRelationship(
|
||||
) {
|
||||
const shouldRemoveRelated = !!cascades.delete?.includes(relationship.name)
|
||||
|
||||
OneToMany({
|
||||
const options: Parameters<typeof OneToMany>[0] = {
|
||||
entity: relatedModelName,
|
||||
orphanRemoval: true,
|
||||
mappedBy: relationship.mappedBy || camelToSnakeCase(MikroORMEntity.name),
|
||||
cascade: shouldRemoveRelated
|
||||
? (["persist", "soft-remove"] as any)
|
||||
: undefined,
|
||||
})(MikroORMEntity.prototype, relationship.name)
|
||||
}
|
||||
|
||||
if (shouldRemoveRelated) {
|
||||
options.cascade = ["persist", "soft-remove"] as any
|
||||
}
|
||||
|
||||
OneToMany(options)(MikroORMEntity.prototype, relationship.name)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user