My data structure looks like this:
{
customer: 10000001,
metadata: {
foo: '10.4',
bar: 99
}
}
Unfortunately there is a mistake in my dataset as all values for 'metadata.foo' have been stored as a string. There are 500 affected documents (the value is optional), so it is not possible to correct the values manually.
Is it possible to replace the string value with its float value if it is existing at all by terminal without executing some JavaScript code?
I'm thinking of something like:
db.collection.update(
{
'metadata.foo': { $exists: true }
},
{
$toDecimal: <expression??>
}
)