所以我之前有過這個問題,我在這個問題下面得到了一個有效的答案,但我才意識到我提出的查詢沒有按計劃工作。基本上現在如果它像這樣工作(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)...)
- 1 回答
- 0 關注
- 85 瀏覽
添加回答
舉報
0/150
提交
取消