mongo 通过js操作数据库
zllovewyh
9年前
来自: http://my.oschina.net/u/2246523/blog/605879
1. 编写js代码,放到一个js文件中:update_content.js,代码如下:
db.auth("redlichee","redlichee");
var cursor = db.sm_content.find({"category":"notice"});
while(cursor.hasNext())
{
var temp = cursor.next();
db.xf_message_center.update({"content_url_id":temp._id},{$set:{"content":temp.content}});
}
cursor = db.sm_content.find({"category":"public"});
while(cursor.hasNext())
{
var temp = cursor.next();
db.xf_message_center.update({"content_url_id":temp._id},{$set:{"content":temp.content}});
}
2. 进入mongo/bin目录,执行命令
./mongo 10.116.116.240:27017/redlichee --shell /yqy/update_content.js