Created
July 25, 2017 06:17
-
-
Save MOOOWOOO/517b061e1665246e6431ab728d741837 to your computer and use it in GitHub Desktop.
更新mongodb一个集合的某个字段的类型
This file contains 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
db.getCollection('years3').find().forEach(function(doc) { | |
var a = String(doc.date); | |
var d = new Date(a.substr(0,4)+'/'+a.substr(4,2)+'/'+a.substr(6,2)); | |
db.getCollection('years3').update( {_id: doc._id}, {$set: {date: d}}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment