chore(): Improve internal repository delete algo (#11601)

* chore(): Improve internal repository delete algo

* chore(): Improve internal repository delete algo

* chore(): Improve internal repository delete algo

* update tests

* Create purple-donkeys-learn.md

* update tests
This commit is contained in:
Adrien de Peretti
2025-02-25 19:59:57 +01:00
committed by GitHub
parent d814d9540e
commit b42f151be3
14 changed files with 89 additions and 82 deletions
@@ -272,10 +272,11 @@ export class ProductCategoryRepository extends DALUtils.MikroOrmBaseTreeReposito
return [this.sortCategoriesByRank(categoriesTree), count]
}
async delete(ids: string[], context: Context = {}): Promise<void> {
async delete(ids: string[], context: Context = {}): Promise<string[]> {
const manager = super.getActiveManager<SqlEntityManager>(context)
await this.baseDelete(ids, context)
await manager.nativeDelete(ProductCategory.name, { id: ids }, {})
return ids
}
async softDelete(
@@ -163,8 +163,8 @@ export default class ProductCategoryService {
async delete(
ids: string[],
@MedusaContext() sharedContext: Context = {}
): Promise<void> {
await this.productCategoryRepository_.delete(ids, sharedContext)
): Promise<string[]> {
return await this.productCategoryRepository_.delete(ids, sharedContext)
}
@InjectTransactionManager("productCategoryRepository_")