gpt4 book ai didi

firebase - Firestore 查询比较没有数组包含的两个数组

转载 作者:行者123 更新时间:2023-12-04 13:35:16 25 4
gpt4 key购买 nike

是否可以在没有“array-contains”的情况下比较 Firestore 查询中的两个数组?
像这样的东西:

    query = query.where(
"info.currentLocation",
"==",
currentUserBasicInfo.currentLocation
);
info.currentLocationcurrentUserBasicInfo.currentLocation都是具有映射值的数组。我无法更改数据结构,并且查询中已经有一个“数组包含”。因为这两个数组必须相同才能运行,所以我觉得必须有一种方法来比较两个数组,而不必使用“array-contains”或“array-contains-any”或“IN”。
有什么建议?这可能吗?

最佳答案

“array-contains”方法能够查询数组[1]中的元素。这意味着您可以将元素保留为数组,并轻松查询它们而无需求助于 map hack。
如果您不想使用此方法,另一种方法是迭代两个数组,直到匹配您需要的值。
但是,在本文档 [2] 中,您可以找到多个用于执行简单和复合查询的示例。
[1] https://firebase.google.com/docs/firestore/query-data/queries
[2] https://firebase.googleblog.com/2018/08/better-arrays-in-cloud-firestore.html

关于firebase - Firestore 查询比较没有数组包含的两个数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62520495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com