【问题标题】:What is the meaning of the return value of com.allanbank.mongodb.MongoCollection.insert(Durability arg0, DocumentAssignable... arg1) [closed]com.allanbank.mongodb.MongoCollection.insert(Durability arg0, DocumentAssignable... arg1) 的返回值是什么意思 [关闭]
【发布时间】:2023-04-03 07:19:01
【问题描述】:

返回值

com.allanbank.mongodb.MongoCollection.insert(Durability arg0, DocumentAssignable... arg1) 

int

当我尝试打印返回值时,我得到了 0。该值被正确插入。

问题:目前还不清楚返回值0是什么意思。所以我希望有人向我解释一下插入函数的返回值的含义,因为文档不是很清楚。

那个 int 值代表什么?

【问题讨论】:

  • 你能详细说明一下这个问题吗?
  • 文档是怎么说的?
  • @pst, "MongoCollection.insert(Durability Durability, DocumentAssignable...documents) 将一组文档插入到集合中。"只有那么多
  • @abhips 我认为你发现了一个错误。在这一点上,我不确定它是在 MongoDB 中还是在驱动程序中,但插入结果中的“n”似乎总是返回为零。
  • 嗨@RobMoore,实际上我尝试了一个简单的示例并通过mongo shell检查了数据库。虽然我正确插入了值,但返回值为 0。

标签: java mongodb asynchronous insert driver


【解决方案1】:

docs 是这么说的

插入的文档数。如果持久性是 NONE 那么这个 值为 -1。

所以返回值0表示,插入的文档数为0(none)。

【讨论】:

  • 实际上 - 文档是错误的。 MongoDB 服务器在插入“n”字段时总是返回零,该字段应该是受影响的文档数。见jira.mongodb.org/browse/SERVER-4381
猜你喜欢
  • 1970-01-01
  • 2013-04-25
  • 2014-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-13
相关资源
最近更新 更多