//type:2代表String
1.String变Double
db.集合.find({"列":{$type:2}}).forEach(function(x){
x.列=parseFloat(x.列);db.order.save(x)
})
db.order.find({"saleprice":{$type:2}}).forEach(function(x){x.saleprice=parseFloat(x.saleprice);db.order.save(x)})
2.关系数据库 insert into select MongoDB的实现
思路:根据条件查询,遍历插入
MongoDB Enterprise > db.product.find({yys:99}).forEach(function(x){x.yys=36;x._i
d=new ObjectId().str;db.product.insert(x)})
3.db.product.update({'province':'内蒙古'},{$set:{'province':'内蒙'}},{multi:true})--所有的内幕古改成内幕
类型 | 对应数字 | 别名 | 说明 |
Double | 1 | double | |
String | 2 | string | |
Object | 3 | object | |
Array | 4 | array | |
Binary data | 5 | binData | |
Undefined | 6 | undefined | 弃用 |
ObjectId | 7 | objectId | |
Boolean | 8 | “bool” | |
Date | 9 | “date” | |
Null | 10 | “null” | |
Regular Expression | 11 | “regex” | |
DBPointer | 12 | “dbPointer” | |
JavaScript | 13 | “javascript” | |
Symbol | 14 | “symbol” | |
JavaScript(with scope) | 15 | “javascriptWithScope” | |
32-bit integer | 16 | “int” | |
Timestamp | 17 | “timestamp” | |
64-bit integer | 18 | “long” | |
Min key | -1 | “minKey” | |
Max key | 127 | “maxKey” |