繁体   English   中英

如何在firebase firestore中搜索多个字段的值?

[英]How to search multiple fields for a value in firebase firestore?

把我的头撞在砖墙上试图理解这一点。

试过了|| 这似乎不起作用,下面的数组似乎也不起作用。

我需要在集合下的每个文档中搜索三个不同的 Firestore 字段(fiftyVoucher、百券、百券)以查找 uuid 匹配。

如果在其中一个文档中未找到 uuid,我还尝试在下一个字段中进行另一次搜索,但这似乎不起作用……但我可能做错了。

欢迎任何建议或指示,因为我在任何地方都找不到答案!

    onSuccess = e => {
    e.data === specialVoucherCode ? 
    ScanSuccess()
    :
    firestore()
      .collection('users')
      .where('fiftyVoucher', '==', e.data)
      .get()
      .then(doc => {
        doc.forEach(user => {
         if(user.length == 0) ScanFail()
          let freshBalance = user.data().points - 50 ;
          firestore()
            .collection('users')
            .doc(user.id)
            .update({
              points: freshBalance,
              fiftyVoucher: '',
            })
            .then(() => {
              console.log({freshBalance})
              Alert.alert('🎉Hooray🎉', 'Voucher claimed');
              navigation.navigate('secretMenuOptions');
            });
        });
      });
  };

在我寻找fiftyVoucher我还需要在hundredVoucherhundredFiftyVoucherhundredVoucher ,直到找到它,然后删除适当数量的点。 在此之后,我能否在这些领域中进行第二轮和第三轮“搜索”……我该怎么做?

提前致谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM