Update product.js

This commit is contained in:
Philip Korsholm
2021-10-21 18:01:59 +02:00
committed by GitHub
parent 1bd13a6dd7
commit ac5b747490
+15 -15
View File
@@ -463,26 +463,26 @@ class ProductService extends BaseService {
* castable as an ObjectId * castable as an ObjectId
* @return {Promise} empty promise * @return {Promise} empty promise
*/ */
async delete(productId) { // async delete(productId) {
return this.atomicPhase_(async (manager) => { // return this.atomicPhase_(async (manager) => {
const productRepo = manager.getCustomRepository(this.productRepository_) // const productRepo = manager.getCustomRepository(this.productRepository_)
// Should not fail, if product does not exist, since delete is idempotent // // Should not fail, if product does not exist, since delete is idempotent
const product = await productRepo.findOne({ where: { id: productId } }) // const product = await productRepo.findOne({ where: { id: productId } })
if (!product) return Promise.resolve() // if (!product) return Promise.resolve()
await productRepo.softRemove(product) // await productRepo.softRemove(product)
await this.eventBus_ // await this.eventBus_
.withTransaction(manager) // .withTransaction(manager)
.emit(ProductService.Events.DELETED, { // .emit(ProductService.Events.DELETED, {
id: productId, // id: productId,
}) // })
return Promise.resolve() // return Promise.resolve()
}) // })
} // }
/** /**
* Adds an option to a product. Options can, for example, be "Size", "Color", * Adds an option to a product. Options can, for example, be "Size", "Color",