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:
Adrien de PerettiandCarlos R. L. Rodrigues authored and GitHub committed 2025-02-26 09:53:13 +00:00
1 parent a35c9ed741
commit eeebb35758
9 files changed
+277 -130

No files matched your search

@@ -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)
}
/**