给某一collection 添加一个string类型的字段
mon shell怎么写
var _name= new String("*网");
db.Novel_News.update({"novelSupplier": { $exists: false }}, {$set: {"novelSupplier": _name}},false,true);

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
mongo 为nosql 不需要定义数据结构
要是想给某些数据添加一个新字段
db.collection.update(query,{"$set":{"newField":"value"}})
参考:
db.testtab.update({},{$set : { newcol : ''}}, {multi : true})
细节可以参考官方手册的$set操作符的具体说明来使用。