diff --git a/src/services/storage/paymentStorage.ts b/src/services/storage/paymentStorage.ts index dc2ec847..092ef8df 100644 --- a/src/services/storage/paymentStorage.ts +++ b/src/services/storage/paymentStorage.ts @@ -138,7 +138,15 @@ export default class { } async RemoveUserInvoices(userId: string, txId?: string) { - return this.dbs.Delete('UserReceivingInvoice', { user: { user_id: userId } }, txId) + const invoices = await this.dbs.Find('UserReceivingInvoice', { where: { user: { user_id: userId } } }, txId) + if (invoices.length === 0) { + return 0 + } + let deleted = 0 + for (const invoice of invoices) { + deleted += await this.dbs.Delete('UserReceivingInvoice', invoice.serial_id, txId) + } + return deleted } async GetAddressOwner(address: string, txId?: string): Promise { @@ -322,7 +330,15 @@ export default class { } async RemoveUserEphemeralKeys(userId: string, txId?: string) { - return this.dbs.Delete('UserEphemeralKey', { user: { user_id: userId } }, txId) + const keys = await this.dbs.Find('UserEphemeralKey', { where: { user: { user_id: userId } } }, txId) + if (keys.length === 0) { + return 0 + } + let deleted = 0 + for (const key of keys) { + deleted += await this.dbs.Delete('UserEphemeralKey', key.serial_id, txId) + } + return deleted } async AddPendingUserToUserPayment(fromUserId: string, toUserId: string, amount: number, fee: number, linkedApplication: Application, txId: string) { diff --git a/src/services/storage/productStorage.ts b/src/services/storage/productStorage.ts index e6f2f662..75f3da0d 100644 --- a/src/services/storage/productStorage.ts +++ b/src/services/storage/productStorage.ts @@ -21,6 +21,14 @@ export default class { } async RemoveUserProducts(userId: string, txId?: string) { - return this.dbs.Delete('Product', { owner: { user_id: userId } }, txId) + const products = await this.dbs.Find('Product', { where: { owner: { user_id: userId } } }, txId) + if (products.length === 0) { + return 0 + } + let deleted = 0 + for (const product of products) { + deleted += await this.dbs.Delete('Product', { product_id: product.product_id }, txId) + } + return deleted } } \ No newline at end of file