I have a MongoDB Collection with objects of type:
{
id: 1223
items: [{
length: 12.233333,
}, {
length: 4.2323232323232,
}]
}
How can I update the length
of each item by rounding to 2 decimals.
I have a MongoDB Collection with objects of type:
{
id: 1223
items: [{
length: 12.233333,
}, {
length: 4.2323232323232,
}]
}
How can I update the length
of each item by rounding to 2 decimals.
2
Answers
You can use
$round
operator like this:Playground link.
Try this one:
Mongo Playground