1 回答
慕码人8056858
TA贡献1803条经验 获得超6个赞
它没有记录在案,但常识Collection.FindOne()
暗示Limit=1
. 的返回值Collection.FindOne()
不允许访问多个结果文档,这就是为什么options.FindOne
甚至没有SetLimit()
方法的原因。
如果你检查源代码,它就在那里:
// Unconditionally send a limit to make sure only one document is returned and the cursor is not kept open
// by the server.
findOpts = append(findOpts, options.Find().SetLimit(-1))
请注意,FindOptions.Limit
文件说明:
// Limit is the maximum number of documents to return. The default value is 0, which means that all documents matching the
// filter will be returned. A negative limit specifies that the resulting documents should be returned in a single
// batch. The default value is 0.
Limit *int64
- 1 回答
- 0 关注
- 100 浏览
添加回答
举报
0/150
提交
取消