mongodb 将字符串时间改为ISO时间 - xd21303/Notebook GitHub Wiki

将字符串格式的publish_time 改为ISO时间格式.

ca = collection.aggregate([
    { "$addFields": {
        "publish_time": {
            "$toDate": "$publish_time"
        }
    } }
])

备份原有collection

删除原有collection

重新插入ca

collection.insert_many(ca)