时间:2021-07-01 10:21:17 帮助过:42人阅读
db.person.find({address:{$type:2}}) //查询address字段数据类型为字符串
db.person.find({address:{$type:"string"}}) //查询address字段数据类型为字符串
二.类型转换
假设有表item_infoY(stae,time,date)
//string转为double类型
db.item_infoY.find().forEach( function (x) {
x.state = parseInt(x.state);
db.item_infoY.save(x);
});
//string转为int类型
db.item_infoY.find().forEach( function (x) {
x.time = NumberInt(x.time);
db.item_infoY.save(x);
});
//string转化为date类型
db.item_infoY.find().forEach( function (x) {
x.date = new ISODate(x.date);
db.item_infoY.save(x);
});
MongoDB类型转换
标签:ble mongodb double oda function person mongo span date