Now I try to insert data with NumberDecimal (In Mongo Shell)
// Invoice
{
_id: "1",
date: ,
name: 'Maly',
amount: NumberDecimal('0.3')
}
-----------------
// Payment
{
_id : "1",
date : ,
paid : NumberDecimal('0.2'),
invoiceId: "1"
},
{
_id : "2",
date : ,
paid : NumberDecimal('0.1'),
invoiceId: "1"
}
And then It work fine
db.invoices.aggregate([
............. // lookup to payment
{
$group:{
_id: null,
totalPaid: {$sum: "$paid"}
}
}
........ // project the balance field, and set status
])
----------------
// Result
{
"_id" : null,
"sum" : 0.3
}
