使用REST API的Firebase过滤器记录(活动vs非活动) [英] Firebase filter records using the REST API (active vs inactive)

查看:143
本文介绍了使用REST API的Firebase过滤器记录(活动vs非活动)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司正在考虑将Firebase用于处理大量动态表单的特定项目。我们希望在开始之前删除Firebase服务中的一些标志。



首先,我已阅读博客帖子:



https ://www.firebase.com/blog/2013-10-01-queries-part-one.html



https://www.firebase.com/blog/2014-01-02-queries- part-two.html



他们提出的基本查询是非常明显的,我相信对于项目报表查询来说是足够的,但是这仅仅是可用的为Web API?有没有一种方法可以从REST API搜索或获取来自Firebase的过滤数据,还是由开发人员在这里过滤一堆数据?



我的问题源于从一些需要根据我们计划卸载到Firebase的数据显示报表的情侣模式。

例如:

$ pre $ 网站(内部托管)
activeSurveyId:* firebase调查ID *

调查(通过Firebase托管)
siteId: *此网站的此Firebase调查属于*
状态:正在进行中
...

如果我只是想为一个简单的网站进行调查,但是如果我想编译一份所有调查问卷的状态为正在进行的报告,有没有一种简单的方法可以通过REST API来实现? p>

我很喜欢使用这款产品,因为它非常漂亮。我们只需要确保它符合我们的要求,而不必在我们的结束进行过滤/搜索一堆额外的工作。

就像在Firebase(和其他noSql数据库)中查询许多问题一样,答案是避免进行复杂的查询。构建数据以减少或消除对查询的需求。

Firebase有关于此的博客条目,反规范化您的数据是正常的,我建议您阅读。



要解决您的具体问题,最好的方法是将正在进行的调查存储在与完成的不同的根节点中。您的结构可能如下所示:

 surveys:{
in-progress:{
-JTICjjZfm8faeMo11FF:{...一次调查的数据...},
...
}
完成:{
-JTICdawddwMo11DWCwd: {...一次调查的数据...},
...
}
}


My company is considering using Firebase for a particular project dealing with massive dynamic forms. There have been some flags raised with the Firebase service that I would like to remove before we start.

First off I've read through the blog posts here:

https://www.firebase.com/blog/2013-10-01-queries-part-one.html

https://www.firebase.com/blog/2014-01-02-queries-part-two.html

The basic queries they outline are pretty self explanatory and I believe will be enough for the projects reporting inquiries, however is this only available for the Web API? Is there a way to search or get filtered data from Firebase from the REST API or is it up to the developers here to filter through a bunch of data?

My problem stems from a couple models that need to show reports based off some of the data we plan to offload to Firebase.

For example:

Site (Hosted internally)
  activeSurveyId: *firebase survey id*

Survey (Hosted through Firebase)
  siteId: *site this firebase survey belongs to*
  status: "In Progress"
  ...

If I just wanted the survey for a site that's simple, however if i wanted to compile a report of all Survey's with the status of "In Progress" is there a simple way to do that from the REST API?

I'd love to use this product as it's quite slick. We just need to make sure it meets our requirements without doing a bunch of extra work on our end for filtering / searching.

解决方案

As is the case with a lot of questions about querying in Firebase (and other noSql databases), the answer is to avoid the need to make complex queries. Structure your data to reduce or eliminate the need for queries.

Firebase has a blog entry about this, Denormalizing Your Data is Normal, which I recommend you read.

To resolve your specific issue, your best bet is to store the surveys that are in progress in a different root node than those that are completed. Your structure might look something like this:

"surveys": {
    "in-progress": {
        "-JTICjjZfm8faeMo11FF": { ... data for one survey ... },
        ... 
     }
    "completed": {
        "-JTICdawddwMo11DWCwd": { ... data for one survey ... },
        ... 
     }
}

这篇关于使用REST API的Firebase过滤器记录(活动vs非活动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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