Created
June 15, 2017 11:10
-
-
Save nainglinaung/c27850af99ecc0ee12678a598f1372dc to your computer and use it in GitHub Desktop.
Change type in field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var devices = db.getCollection('devices').aggregate([ | |
{ "$group" : {_id:"$something" } } | |
]); | |
var batch = devices._batch; | |
for(i=0; i<=batch.length; i++) { | |
if (batch[i]) { | |
if (batch[i]._id) { | |
if (typeof(batch[i]._id) == 'number') { | |
db.devices.update({something:batch[i]._id},{$set : { something: batch[i]._id.toString() } },{multi:true}) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment