1 回答

TA貢獻1803條經(jīng)驗 獲得超6個贊
它沒有記錄在案,但常識Collection.FindOne()
暗示Limit=1
. 的返回值Collection.FindOne()
不允許訪問多個結(jié)果文檔,這就是為什么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 關(guān)注
- 128 瀏覽
添加回答
舉報