第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 go mongo-driver 中為 options.FindOne() 設(shè)置限制

如何在 go mongo-driver 中為 options.FindOne() 設(shè)置限制

Go
慕尼黑8549860 2023-03-07 16:45:12
我看到有一種方法可以SetLimit()用于Find()func,但我沒有看到任何設(shè)置限制的選項FindOne(),因為我們正在搜索單個結(jié)果,所以FindOne()我們甚至不必限制它?它自動處理限制?嘗試使用 1options.FindOne()` 設(shè)置限制,但我看不到這樣做的方法。
查看完整描述

1 回答

?
慕碼人8056858

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


查看完整回答
反對 回復(fù) 2023-03-07
  • 1 回答
  • 0 關(guān)注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號