I want to add the property type
as billing
to the result of a mongodb operation. I treid many answers from Is it possible to add dynamically named properties to JavaScript object?, like this one: https://stackoverflow.com/a/46512466/6655884 here:
let r1 = await Billing.find({
launchDate: {
"$gte": new Date(req.query.minDate),
"$lte": new Date(req.query.maxDate)
},
deleted: false,
status: "pago"
});
r1.map((obj)=>({...obj,['type']:"billing"}));
But when I print r1
, there's no type
property.
UPDATE:
What about
for (var i=0; i<r1.length; i++) {
r1[i]['type'] = "billing";
}
?
It doesn't work either