2017-10-30 100 views
8

Firestore sorgusunda mantıksal OR operatörünü çalıştırmayı deniyorum.Firestore sorgusunda OR uygulanıyor - Firebase firestore

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


      //Some processing on dataSnapshot 
}) 

Ama bu doğru uygulamak için bir yol VEYA değildir.

Tüm kullanıcıların 'Maker, Checker veya Approver' rollerini istiyorum.

Nasıl firestore sorgusunda OR uygularım? Doc'ta hiçbir şey yok.

+0

Varsayılan rol nedir? – Hareesh

cevap

8

Cloud Firestore'da "VEYA" sorgusu yok. Bunu tek bir sorguda gerçekleştirmek istiyorsanız, maker_or_checker_or_approver: true gibi tek bir alana ihtiyacınız olacaktır.

Elbette her zaman üç sorgu yapabilir ve bunlara istemcide katılabilirsiniz.

+0

3 sorgu yapıyorum. Ben böyle yapıyorum. Evet –

+1

Yani, eğer twitter gibi bir şey söyleyeyim ve sadece takip ettiğim insanların tweet'lerini görmek istiyorum, 'tweets.where (user == john OR lisa OR julia) 'diyemiyorum? –

+0

Bu doğru, bir sorguda bunu yapamazsınız. –