欢迎投稿

今日深度:

MongoDB脚本获取update操作的影响记录数

MongoDB脚本获取update操作的影响记录数


运行getlasterror可以获得最后一次操作影响的结果。

比如: 

> db.display.update({$where: function() {return new Date().getTime() / 1000 - this.last_active_time > 300}, status: "offline"}, {$set: {status: "online"}}, false, true)
> db.runCommand("getlasterror")
{
	"updatedExisting" : true,
	"n" : 1495,
	"connectionId" : 38,
	"err" : null,
	"ok" : 1
}
> var j = db.runCommand("getlasterror")
> j.n
1495

www.htsjk.Com true http://www.htsjk.com/DB2/20164.html NewsArticle MongoDB脚本获取update操作的影响记录数 运行getlasterror可以获得最后一次操作影响的结果。 比如: db.display.update({$where: function() {return new Date().getTime() / 1000 - this.last_active_time 300}, status: o...
评论暂时关闭