diff --git a/backend/models/PointTransaction.js b/backend/models/PointTransaction.js index 389b621..819288e 100644 --- a/backend/models/PointTransaction.js +++ b/backend/models/PointTransaction.js @@ -90,7 +90,7 @@ class PointTransaction { const errorContext = createErrorContext('PointTransaction', 'findByUser', { userId, limit, skip }); return await withErrorHandling(async () => { - const result = await couchdbService.find({ + const docs = await couchdbService.find({ selector: { type: 'point_transaction', user: userId @@ -99,7 +99,7 @@ class PointTransaction { limit: limit, skip: skip }); - return result.docs; + return docs; }, errorContext); } @@ -107,7 +107,7 @@ class PointTransaction { const errorContext = createErrorContext('PointTransaction', 'findByType', { transactionType, limit, skip }); return await withErrorHandling(async () => { - const result = await couchdbService.find({ + const docs = await couchdbService.find({ selector: { type: 'point_transaction', transactionType: transactionType @@ -116,7 +116,7 @@ class PointTransaction { limit: limit, skip: skip }); - return result.docs; + return docs; }, errorContext); } @@ -144,7 +144,7 @@ class PointTransaction { return await withErrorHandling(async () => { // Get the most recent transaction for the user to find current balance - const result = await couchdbService.find({ + const transactions = await couchdbService.find({ selector: { type: 'point_transaction', user: userId @@ -153,11 +153,11 @@ class PointTransaction { limit: 1 }); - if (result.docs.length === 0) { + if (transactions.length === 0) { return 0; } - return result.docs[0].balanceAfter; + return transactions[0].balanceAfter; }, errorContext); } @@ -180,12 +180,12 @@ class PointTransaction { } } - const result = await couchdbService.find({ + const transactions = await couchdbService.find({ selector: selector, sort: [{ createdAt: 'desc' }] }); - return result.docs; + return transactions; }, errorContext); } @@ -222,4 +222,4 @@ class PointTransaction { } } -module.exports = PointTransaction; \ No newline at end of file +module.exports = PointTransaction;