Hi Everyone,
I am working with the data (generated by the web3 services) which include the balance as gwei, wei etc, which is quite large so I have stored them as string, now I am querying this data (paginated), but need to sort this on the field balance but as turn out it is being sorted on the character instead of the numerical value, which is quite expected but can we sort this based on the numerical value
- I am aware that we can use aggregation but let just say we don’t want use them
const points = await this.pointModel
.find(param, {
address: 1,
totalPoints: 1,
pointsPerProduct: 1,
_id: 0,
})
.sort({
[productId < 0 ? "totalPoints" : `pointsPerProduct.${productId}`]:
sortOrder === "desc" ? -1 : 1,
})
.skip(limit * page)
.limit(limit)
.lean()
.exec()