const search = await searchAgent.aggregate([
{$match: {id: Number(fid), status: {$regex: status, $options: 'i'}}},
{$sort: {[order_by]: order == 'desc' ? -1 : 1}},
{$skip: skip},
{$limit: pagelimit},
])
Here I need to get the total number of documents matching the query. As I am using the limit I can't get the total count of documents.