大佬教程收集整理的这篇文章主要介绍了mongodb updateOne 检查保证数据已设置,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我将 mongodb 4.4.6 与 php 一起使用:
"name": "mongodb/mongodb","version": "1.8.0",
我遇到了奇怪的问题,在使用一组数据执行 updateOne
时出于某种原因
$fIEldsLog = $fIElds;
unset($fIEldsLog['data']);
$this->refreshTokenLogger->info('write session updateOne fIElds - ' . Json_encode($fIEldsLog));
$updateResult = $this->getCollection()->updateOne(
[$this->options['ID_fIEld'] => $sessionID],['$set' => $fIElds],[
'gcProbablity' => 1.0,'upsert' => true
]
);
$this->refreshTokenLogger->info(
'session updateResult - '
. 'MatchedCount - ' . $updateResult->getMatchedCount().
','.'ModifIEdCount - ' . $updateResult->getModifIEdCount() .
','.'UpsertedCount - ' . $updateResult->getUpsertedCount() .
','.'UpsertedID - ' . $updateResult->getUpsertedID()
);
并在日志中检查进程
[2021-06-04T16:47:57.631265+00:00] refresh_token.INFO: write session updateOne fIElds - {"time":{"$date":{"$numberLong":"1622825277622"}},"expires_at":{"$date":{"$numberLong":"1622826717000"}},"user_name":"s@s.com","refresh_token":"5ac32c157c458b48ebd6aab64207472418df28283d1a7b33977e58576d52232af943f2d96cb06e3ea6d520172a541d6f7d92d2fffb3c6e95885e3ad8dd3d3539","user_ip":"172.19.0.4"} [] []
[2021-06-04T16:47:57.633641+00:00] refresh_token.INFO: session updateResult - MatchedCount - 1,ModifIEdCount - 1,UpsertedCount - 0,UpsertedID - [] []
但是在收集中我遇到了旧的,而不是应该记录的数据 - 应该是这个哈希 - 5ac32c157c458b48ebd6aab64207472418df28283d1a7b33977e58576d52232af943f2d96cb06e3ea6d520172a541d6f7d92d2fffb3c6e95885e3ad8dd3d3539
并且日志文件修复了这个问题,ModifIEdCount 和 MatchedCount 为 1,看起来一切正常。
是否可以保证我确实已经注册了数据库?或者如何捕捉碰撞或关于为什么没有记录这些数据的错误
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的mongodb updateOne 检查保证数据已设置全部内容,希望文章能够帮你解决mongodb updateOne 检查保证数据已设置所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。