I want to sum total of amount with the type string in array so I write this in mongo. any help please
Tried :
db.compte.aggregate([
{$project:{
account: "$auditMessages.eventMetaData.Counterparty Name",
amount: "$auditMessages.eventMetaData.Transaction Amount",
"total": {$sum:"$amount"}
}}])
The result:
{
"_id" : ObjectId("5ed638e566a699750cbb1b0f"),
"account" : [
"Mr Jalel CHAHED",
"Mr Jalel CHAHED",
"Mr Jalel CHAHED",
"Mr Jalel CHAHED"
],
"amount" :
[
"4.32",
"4.32",
"1.32",
"1.32"
],
"total" : 0}