在firestore查询中实现OR - Firebase firestore [英] Implementing OR in firestore query - Firebase firestore
问题描述
我在firestore查询中尝试实现逻辑OR运算符。
I am trying implement logical OR operator in firestore query.
db.collection('users').where('company_id', '==', companyId)
.where('role', '==', 'Maker')
.where('role', '==', 'Checker')
.where('role', '==', 'Approver')
.get().then(function(adminsSnapshot){
//Some processing on dataSnapshot
})
但这不是实现OR的正确方法。
But this is not the right way to implement OR.
我希望所有用户都拥有'Maker,Checker或Approver'的角色。
I want all users with roles of 'Maker, Checker or Approver'.
我将如何实现OR在firestore查询? Doc中没有任何内容。
How would i implement OR in firestore query ? There's nothing in Doc.
推荐答案
Cloud Firestore中没有OR查询。如果你想在一个查询中实现这一点,你需要一个单独的字段,如 maker_or_checker_or_approver:true
。
There is no "OR" query in Cloud Firestore. If you want to achieve this in a single query you will need a single field like maker_or_checker_or_approver: true
.
Of当然,你总是可以做三个查询并在客户端加入。
Of course you can always do three queries and join them on the client.
这篇关于在firestore查询中实现OR - Firebase firestore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!