$type操作符
检测类型 种类 代号 别名 Double 1 “double” String 2 “string” Object 3 “object” Array 4 “array” Binary data 5 “binData” Undefined 6 “undefined” Deprecated. 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
查看“times”该字段的数据类型: db.getCollection('content').find({"times":{$type:"long"}}) db.getCollection('content').find({"times":{$type:18}}) 更改数据类型 db.getCollection('zl').find({'like' : { $type : 2 }}).forEach(function(x) { x.like = parseInt(x.like); db.getCollection('zl').save(x); })
转载请注明原文地址: https://ju.6miu.com/read-1378.html