1. 編寫js代碼,放到一個js文件中:update_content.js,代碼以下:shell
db.auth("redlichee","redlichee");url
var cursor = db.sm_content.find({"category":"notice"});code
while(cursor.hasNext())date
{next
var temp = cursor.next();db
db.xf_message_center.update({"content_url_id":temp._id},{$set:{"content":temp.content}});文件
}auth
cursor = db.sm_content.find({"category":"public"});while
while(cursor.hasNext())co
{
var temp = cursor.next();
db.xf_message_center.update({"content_url_id":temp._id},{$set:{"content":temp.content}});
}
2. 進入mongo/bin目錄,執行命令
./mongo 127.0.0.1:27017/redlichee --shell /yqy/update_content.js