使用mongo shell轉換字符類型
阿新 • • 發佈:2017-09-29
time pad scope double body col define min reg
MongoDB數據類型如下:
類型 | 對應數字 | 別名 | 說明 |
Double1 | 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” |
js修改語句:
db.getCollection(‘log_pages_day‘).find( {‘uv‘ : { $type : 18 }} ).forEach(function(x) { x.uv =NumberInt(x.uv); db.log_pages_day.save(x); })
使用mongo shell轉換字符類型