亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

使用bolthold 3個條件去boltDB查詢

使用bolthold 3個條件去boltDB查詢

Go
素胚勾勒不出你 2022-12-13 16:08:24
所以我之前有過這個問題,我在這個問題下面得到了一個有效的答案,但我才意識到我提出的查詢沒有按計劃工作。基本上現在如果它像這樣工作(if the roleskey contains any of the roles in slice) and (if the tenantID is an empty string) or (if tenantIDKey is equal to tenantID)但我需要的是(if the roleskey contains any of the roles in slice) AND (if the tenantID is an empty string OR if tenantIDKey is equal to tenantID)這是我當前的查詢:query := bolthold.Where(roleskey).ContainsAny(bolthold.Slice(roles)...).And(tenantIDKey).Eq("").Or(bolthold.Where(tenantIDKey).Eq(tenantID))有誰知道如何解決這個問題?
查看完整描述

1 回答

?
慕尼黑8549860

TA貢獻1818條經驗 獲得超11個贊

嘗試:

query := bolthold.
         Where(tenantIDKey).Eq("").
         Or(
           bolthold.
           Where(tenantIDKey).
           Eq(tenantID)
         ).
         And(roleskey).
         ContainsAny(bolthold.Slice(roles)...)

或者

query := bolthold.
         Where(tenantIDKey).ContainsAny("", tenantID).
         And(roleskey).
         ContainsAny(bolthold.Slice(roles)...)

或者

query := bolthold.
         Where(tenantIDKey).In("", tenantID).
         And(roleskey).
         ContainsAny(bolthold.Slice(roles)...)


查看完整回答
反對 回復 2022-12-13
  • 1 回答
  • 0 關注
  • 85 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號