mongo的脚本是js语法,所以存储过程也是js语法。

 

创建:

db.system.js.save(
  {
    _id: "saveAndCount",      
    value : function(x) { 
        for(var i=0;i<x;i++){
           db.[表名].save(
           {
                "status" : "200",
                "msg" : "登陆状态"
            }
           );
        }
        return db.getCollection('xxx').find({}).count(); 
        }    
  })

 

查询:

 db.system.js.find()

 

删除:

 db.system.js.remove({"_id" : "saveAndCounts(10)"});

 

执行:

use [库名]
db.eval("saveAndCount(1)")

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-02-24
  • 2021-09-06
  • 2022-01-06
猜你喜欢
  • 2022-02-03
  • 2022-01-01
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-11-27
相关资源
相似解决方案