在firestore查询中实现OR - Firebase firestore

Nom*_*Ali 19 javascript firebase google-cloud-firestore

我在firestore查询中尝试实现逻辑OR运算符.

db.collection('users').where('company_id', '==', companyId)
                          .where('role', '==', 'Maker')
                          .where('role', '==', 'Checker')
                          .where('role', '==', 'Approver')
                          .get().then(function(adminsSnapshot){


             //Some processing on dataSnapshot
})
Run Code Online (Sandbox Code Playgroud)

但这不是实施OR的正确方法.

我希望所有用户都拥有"Maker,Checker或Approver"角色.

我如何在firestore查询中实现OR?Doc中没有任何内容.

Sam*_*ern 13

Cloud Firestore中没有"OR"查询.如果要在单个查询中实现此目的,则需要一个单独的字段maker_or_checker_or_approver: true.

当然,您始终可以执行三个查询并在客户端上加入它们.

  • 这是正确的,你不能在一个查询中这样做. (2认同)