fix: not fetche withdraw request
This commit is contained in:
@@ -106,26 +106,36 @@ module.exports.getAllForAdmin = async (req, res) => {
|
||||
}
|
||||
: {}
|
||||
|
||||
const aggregationPipeline = [
|
||||
{ $match: matchStage },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
localField: 'userId',
|
||||
foreignField: '_id',
|
||||
as: 'userId'
|
||||
}
|
||||
},
|
||||
{ $unwind: '$userId' },
|
||||
{ $sort: { [sortField]: sortOrder } },
|
||||
{ $skip: skip },
|
||||
{ $limit: rows }
|
||||
]
|
||||
// const aggregationPipeline = [
|
||||
// { $match: matchStage },
|
||||
// {
|
||||
// $lookup: {
|
||||
// from: 'usergps',
|
||||
// localField: 'userId',
|
||||
// foreignField: '_id',
|
||||
// as: 'userId'
|
||||
// }
|
||||
// },
|
||||
// { $unwind: '$userId' },
|
||||
// { $sort: { [sortField]: sortOrder } },
|
||||
// { $skip: skip },
|
||||
// { $limit: rows }
|
||||
// ]
|
||||
// const data = await Withdraw.aggregate(aggregationPipeline)
|
||||
const data = await Withdraw.find(matchStage)
|
||||
.sort({ [sortField]: sortOrder })
|
||||
.skip(skip)
|
||||
.limit(rows)
|
||||
.populate('userId')
|
||||
|
||||
const [data, totalDocuments] = await Promise.all([
|
||||
Withdraw.aggregate(aggregationPipeline),
|
||||
Withdraw.countDocuments(matchStage)
|
||||
])
|
||||
const totalDocuments = await Withdraw.countDocuments(matchStage)
|
||||
|
||||
console.log(data)
|
||||
|
||||
// const [data, totalDocuments] = await Promise.all([
|
||||
// Withdraw.aggregate(aggregationPipeline),
|
||||
// Withdraw.countDocuments(matchStage)
|
||||
// ])
|
||||
|
||||
const totalPages = Math.ceil(totalDocuments / rows)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user