mongo 经过js操做数据库

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
相关文章
相关标签/搜索