所以我之前有過(guò)這個(gè)問(wèn)題,我在這個(gè)問(wèn)題下面得到了一個(gè)有效的答案,但我才意識(shí)到我提出的查詢沒(méi)有按計(jì)劃工作?;旧犀F(xiàn)在如果它像這樣工作(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)這是我當(dāng)前的查詢:query := bolthold.Where(roleskey).ContainsAny(bolthold.Slice(roles)...).And(tenantIDKey).Eq("").Or(bolthold.Where(tenantIDKey).Eq(tenantID))有誰(shuí)知道如何解決這個(gè)問(wèn)題?
1 回答

慕尼黑8549860
TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超11個(gè)贊
嘗試:
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 關(guān)注
- 79 瀏覽
添加回答
舉報(bào)
0/150
提交
取消