查询对象的Firestore数组 [英] Query firestore array of objects

查看:51
本文介绍了查询对象的Firestore数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有消防站集合 事件 .

I have firestore collection events.

每个 事件 都有 日期 ,这是带有两个字符串的对象数组, startTime endTime .

Every event have date which is array of objects with two strings, startTime and endTime.

是否可以检索列表中有一个大于当前时间的 startTime 的每个 事件 ?

Is it possibile to retrive every events which have at list one startTime which is bigger than current time?

推荐答案

这对于您的文档结构是不可能的.您无法在查询中定位数组元素.相反,您可能希望将max startTime作为顶级字段存储在文档中,并在查询中使用它.

This is not possible with your document structure. You can't target array elements in queries. Instead, you may want to store the max startTime as a top-level field in the document, and use that instead in your queries instead.

像这样复制数据以适合您的查询是很常见的.对于NoSQL数据库,数据结构应始终遵循您要进行的查询.

Duplicating data like this to suit your queries is common. With NoSQL databases, the structure of your data should always follow the queries you intend to make.

这篇关于查询对象的Firestore数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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