Hi,
Each document of my collection “histo” has the following schema:
{
"_id" : ObjectId("5ed61144376edd4a601467cd"),
"pname" : "actual_speed",
"values" : [
{
"timestamp" : 1580120048,
"val" : 27716
},
{
"timestamp" : 1580120113,
"val" : 27730.5
},
{
"timestamp" : 1580120138,
"val" : 27702
},
...
]}
I want to force the type “val” to Double. For the moment, if its value is an integer, as for “27716”, its type is int32.
I tried with:
db.getCollection("histo").find().forEach(function (e) {
e.values.forEach(function (o) {
o.val = parseFloat(o.val);
});
db.getCollection("histo").save(e);
});
But it does not work.
What is wrong ?
Thanks!