In mongo I want to convert for docs in a collection:
{
"timestamp" : 1494624438268.0
}
to
{
"timestamp" : NumberLong(1494624438268)
}
How can I do that?
In mongo I want to convert for docs in a collection:
{
"timestamp" : 1494624438268.0
}
to
{
"timestamp" : NumberLong(1494624438268)
}
How can I do that?
i found it
db.getCollection('collection-name').find().limit(10).forEach(function(data) {
if (data.timestamp instanceof NumberLong === false) {
data.timestamp=NumberLong(data.timestamp);});
You need to select your document and then update with the corresponding type.
db.collection.updateOne( { timestamp: 1494624438268.0 }, { $set: { timestamp: NumberLong("1494624438268") } } )