Skip to content

Commit

Permalink
Merge branch 'update/mongodb'
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyxtralife committed Dec 7, 2023
2 parents 5a89c04 + 93cad31 commit ac90442
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/lib/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,28 +285,25 @@ class TransactionAPI extends AbstractAPI {

const cursor = this.txColl.find(query);
cursor.sort({ ts: -1 });
return cursor.count(function (err, count) {
if (err != null) {
cursor.count()
.then(count => {
cursor.skip(skip).limit(limit).toArray()
.then(transactions => {
transactions.forEach(each => {
delete each._id;
delete each.userid;
});
callback(null, { transactions, count });
})
.catch(err => {
logger.error(err, 'error in txHistory.find.toArray');
callback(err);
});
})
.catch(err => {
logger.error(err, 'error in txHistory.find');
return callback(err);
}

return cursor.skip(skip).limit(limit).toArray(function (err, transactions) {
if (err != null) {
logger.error(err, 'error in txHistory.find.toArray');
return callback(err);
}

for (let each of Array.from(transactions)) {
(function (each) {
delete each._id;
return delete each.userid;
})(each);
}

return callback(null, { transactions, count });
callback(err);
});
});
}
}

Expand Down

0 comments on commit ac90442

Please sign in to comment.