I'm facing the following problem when trying to update some erroneous records in a MongoDB using a NodeJs script.
In my Mongo document there are a lot of entries like:
someKey: {
anotherKey: {
"st_number" : NumberLong(1275956155),
...
}
}
These st_numbers (1275956155 in the example) are wrong and I need to map these values to a 12-digit number like 100060201350 and move the document to a new collection.
The values are deeply nested and occur multiple times in the doc at different locations, which is why my scripts updates the whole document and tries to do a db.collection('..').replaceOne() with the updated values.
After my update-script has run, I see that the value has become a double value, resulting in:
someKey: {
anotherKey: {
"st_number" : 100060201350.0,
...
}
}
In my script I've tried using Long.fromString('100060207234') and Long.fromInt(100060207234) from the mongodb module to force inserting a Long value but both don't work. Any ideas what I'm doing wrong?
via eol
No comments:
Post a Comment