Here is my aggregation query
blockColctn.aggregate([{
"$match": {
"number": blockNumber
}
},
{
"$project": {
"transactions.to": "$transactions.to",
"transaction": "$transactions",
"transactions.hash": "$transactions.hash",
}
},
{
"$lookup": {
"from": "token_collections",
"localField": "transactions.to",
"foreignField": "tokencontractaddress",
"as": "tokenaccount"
}
},
{
"$project": {
"total":getTotal("transactions.hash")
}
}])
I am calling getTotal in $project it works fine, however, I would like to pass transactions.hash column value as the function argument.
I found a similar issue related to mine Custom functions calculated columns mongodb projection
But it doesn't tell about argument passing
blockColctn.aggregate()from? You can create a composable function that takes in the aggregate and getTotal methods