{"size": 900, "ext": "js", "max_stars_repo_path": "MongoTest/DBshell/usedCar_change.js", "max_stars_repo_name": "qingaoti/Trainer", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "MongoTest/DBshell/usedCar_change.js", "max_issues_repo_name": "qingaoti/Trainer", "max_issues_repo_issues_event_min_datetime": "2020-07-16T07:25:39.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-16T07:25:39.000Z", "max_forks_repo_path": "MongoTest/DBshell/usedCar_change.js", "max_forks_repo_name": "qingaoti/Trainer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 33.3333333333, "max_line_length": 86, "alphanum_fraction": 0.5966666667}
var config = require("../../config");
var models = require('huanche-models')(config.MongoSettings);
var constant = require("huanche-models").constant;
var tools = require("huanche-models").tools;
var _ = require("lodash");
var Q = require('q');

function main() {
    var qList = [];
    return models.UsedCar.find({"car_info.mileage": {$type: 2}}).then(function (rst) {
        console.log(`mileage 是 String类型的 有 ${rst.length} 个`);
        rst.forEach(function (item, index) {
            item._doc.car_info.mileage = _.toNumber(item._doc.car_info.mileage);
            qList.push(models.UsedCar.update({_id: item._doc._id}, item));
        });
        return Q.all(qList);
    }).then(function (rst) {
        console.log(`ok ${rst.length} 个`);
    }).catch(function (err) {
        console.log(err);
    }).done(function () {
        console.log('done');
        process.exit();
    });
}

main();