簡體   English   中英

MongoDB奇怪的行為,orOperator

[英]MongoDB strange behaviour, orOperator

我使用spring mongodb java API。 我對orOperator有疑問。 當我使用這樣的標准時,我得到null

 Criteria c1 = Criteria.where(field2).regex("John", "i");
 Criteria c2 = Criteria.where(field1).regex("John", "i");
 new Criteria().orOperator(c1, c1);

而使用給出了我的預期。

new Criteria().andOperator(c1, c1);

我有點困惑,因為Bool'e邏輯,當我說11我應該得到1 你有任何理由嗎?

只想添加使用以下內容產生預期結果。

new Criteria().orOperator(c1);

例如:獲取任何用戶

  query.addCriteria(
        Criteria.where("role").is("user")
          .orOperator(Criteria.where("role").is("manager"))
            .orOperator(Criteria.where("role").is("admin"))
  );

注意:按名稱, 操作員不是操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM