是否可以具有Firestore查询的wherefields或whereFields? [英] Is it possible to have either or whereFields for Firestore query?

查看:55
本文介绍了是否可以具有Firestore查询的wherefields或whereFields?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查询

db.collection("Bookings")
    .whereField("servicer", isEqualTo: userID || "customer", isEqualTo: userID)

与其读取两个不同的内容,不如读取一个,它获取 servicer == userID customer == userID 的所有文档.

Instead of having two different reads it will just have one, and it gets all the documents that servicer == userID and customer == userID.

推荐答案

使用单个查询是不可能的-没有逻辑或操作可用于文档中的多个字段.您将需要有两个查询,一个查询用于"servicer",另一个查询用于"customer",然后在客户端上合并这些查询的结果.

This is not possible with a single query - there is no logical OR operation that works across multiple fields in a document. You will need to have two queries, one for "servicer", and another for "customer", then merge the results of those queries on the client.

这篇关于是否可以具有Firestore查询的wherefields或whereFields?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆