Iām trying to get sum of amounts using a cloud function but I receive overflow error.
Iām using $toLong and the amounts are kept in the database as string
{ācodeā:141,āerrorā:āFailed to parse number ā15000000000000000000ā in $convert with no onError value: Overflowā}
here is the code:
Moralis.Cloud.define(ātotalAmountā, async (request) => {
let query = new Moralis.Query(āPredictionsBetā);
const pipeline = [
{group: {objectId: ā$addressā, totalAmount:{$sum:{$toLong : ā$amountā}}}}
];const result = query.aggregate(pipeline);
return result;
});