mogodb 修改字段属性

修改为decimal类型

db.shopgoods.find({'Pricing.Detail':{$type:2}}).forEach(function(x){x.Pricing.Detail=NumberDecimal(x.Pricing.Detail);db.shopgoods.save(x)})
db.shopgoods.find({'Pricing.Member':{$type:2}}).forEach(function(x){x.Pricing.Member=NumberDecimal(x.Pricing.Member);db.shopgoods.save(x)})

type类型:

Double 1  
String 2  
Object 3  
Array 4  
Binary data 5  
Undefined 6 已废弃。
Object id 7  
Boolean 8  
Date 9  
Null 10  
Regular Expression 11  
JavaScript 13  
Symbol 14  
JavaScript (with scope) 15  
32-bit integer 16  
Timestamp 17  
64-bit integer 18  
Min key 255 Query with -1.
Max key 127  

增加字段

db.CornGoods.update({}, {$set:{"Price.ActualMoney":0}}, {multi: true})
db.CornOrders.update({}, {$set:{"ReceivingTime":ISODate("0001-01-01T08:00:00.000+08:00")}}, {multi: true}) 
 
 
 
原文地址:https://www.cnblogs.com/Celebrator/p/11102563.html