cleanup db fix

This commit is contained in:
shocknet-justin 2026-03-02 14:44:32 -05:00
parent 432f9d0b42
commit 7af841c330
No known key found for this signature in database
2 changed files with 27 additions and 3 deletions

View file

@ -138,7 +138,15 @@ export default class {
} }
async RemoveUserInvoices(userId: string, txId?: string) { async RemoveUserInvoices(userId: string, txId?: string) {
return this.dbs.Delete<UserReceivingInvoice>('UserReceivingInvoice', { user: { user_id: userId } }, txId) const invoices = await this.dbs.Find<UserReceivingInvoice>('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>('UserReceivingInvoice', invoice.serial_id, txId)
}
return deleted
} }
async GetAddressOwner(address: string, txId?: string): Promise<UserReceivingAddress | null> { async GetAddressOwner(address: string, txId?: string): Promise<UserReceivingAddress | null> {
@ -322,7 +330,15 @@ export default class {
} }
async RemoveUserEphemeralKeys(userId: string, txId?: string) { async RemoveUserEphemeralKeys(userId: string, txId?: string) {
return this.dbs.Delete<UserEphemeralKey>('UserEphemeralKey', { user: { user_id: userId } }, txId) const keys = await this.dbs.Find<UserEphemeralKey>('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>('UserEphemeralKey', key.serial_id, txId)
}
return deleted
} }
async AddPendingUserToUserPayment(fromUserId: string, toUserId: string, amount: number, fee: number, linkedApplication: Application, txId: string) { async AddPendingUserToUserPayment(fromUserId: string, toUserId: string, amount: number, fee: number, linkedApplication: Application, txId: string) {

View file

@ -21,6 +21,14 @@ export default class {
} }
async RemoveUserProducts(userId: string, txId?: string) { async RemoveUserProducts(userId: string, txId?: string) {
return this.dbs.Delete<Product>('Product', { owner: { user_id: userId } }, txId) const products = await this.dbs.Find<Product>('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', { product_id: product.product_id }, txId)
}
return deleted
} }
} }