Firestore是脱机模式下使用Node.JS的不错选择吗? [英] Is Firestore a good choice to work with Node.JS in offline mode?

查看:45
本文介绍了Firestore是脱机模式下使用Node.JS的不错选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Raspberry Pi 3上创建了一个简单的Node.js程序,该程序连接到Google Cloud Firestore数据库.目标是让iOS和Android应用程序同时连接到Firestore数据库.

I created a simple Node.js program on my Raspberry Pi 3 that connects to a Google Cloud Firestore database. The goal is to have iOS and Android applications that will connect to the Firestore database at the same time.

脱机然后再次联机时,我发现所有对数据库的请求都已排队,然后推送到Cloud Firestore.

When going offline and then online again, I see that all my requests for the database have been queued and then pushed to Cloud Firestore.

这是我的问题:

  • 请求保存在哪里?
  • 队列的限制是多少?
  • 该队列是否可配置?
  • 我是否正确地说,使用Node.js + Firestore,没有本地存储的数据库可以脱机工作吗?仅适用于移动或网络应用,对吗?
  • 有什么线索,如果Google将拥有Node.js的离线数据库?
  • 有了我要实现的目标,Firestore仍然有意义吗?如果没有,您有建议吗?

预先感谢您的帮助!

推荐答案

Firestore是脱机模式下使用Node.JS的不错选择吗?

Does Firestore is a good choice to work with Node.JS in offline mode?

根据有关 Firestore离线持久性的官方文档:

对于Web,默认情况下禁用离线持久性.要启用持久性,请调用enablePersistence方法.会话之间不会自动清除Cloud Firestore的缓存.因此,如果您的Web应用程序处理了敏感信息,请确保在启用持久性之前先询问用户是否在受信任的设备上.

For the web, offline persistence is disabled by default. To enable persistence, call the enablePersistence method. Cloud Firestore's cache isn't automatically cleared between sessions. Consequently, if your web app handles sensitive information, make sure to ask the user if they're on a trusted device before enabling persistence.

  • 重要:对于网络,离线持久性是一项实验性功能,仅Chrome,Safari和Firefox网络浏览器支持.此外,如果用户打开多个指向同一Cloud Firestore数据库的浏览器选项卡,并且启用了离线持久性,则Cloud Firestore仅在第一个选项卡中可以正常工作.
  • Important: For the web, offline persistence is an experimental feature that is supported only by the Chrome, Safari, and Firefox web browsers. Also, if a user opens multiple browser tabs that point to the same Cloud Firestore database, and offline persistence is enabled, Cloud Firestore will work correctly only in the first tab.

因此,即使此离线持久性是一项实验性功能,您仍然可以在项目中使用它.但是,在使用Node.js时,尚不支持离线持久性.

So even if this offline persistence is an experimental feature, you can still use it in your projects. However, when using Node.js, offline persistence is not yet supported.

请求保存在哪里?

Where are the requests are saved?

Cloud Firestore数据库客户端在内存中保留您正在侦听的所有数据的副本.如果启用脱机持久性,则客户端还将持久性将活动数据和最新数据保存到磁盘.

The Cloud Firestore database client keeps a copy of all data that you're listening to in memory. If you enable offline persistence, the client will also persist active and recent data to disk.

队列的限制是什么?

What is the limit of the queue?

请从此 帖子 中查看我的答案.

Please check my answer from the this post.

该队列是否可配置?

Does that queue is configurable?

不,不是.都是数据库还是什么都没有.

No, it's not. It's all database or nothing.

我是说对了,使用Node.js + Firestore,没有本地存储的数据库可以脱机工作吗?仅适用于移动或网络应用,对吗?

Am I right saying that with Node.js+Firestore, there is no database saved locally to be able to work offline? Only with mobile or web apps, right?

是的.它仅适用于Android和iOS以及网络(实验性).

Yes you are. It only works for Android and iOS and web (experimental).

任何线索是否表明Google将拥有Node.JS的离线数据库?

Any clue if Google will have that offline database for Node.JS?

不,我不知道.您应该向Firebase团队寻求帮助.

No, I don't. You should ask Firebase team for that.

有了我要实现的目标,Firestore仍然有意义吗?如果没有,您有建议吗?

With the goal that I want to achieve, does Firestore still make sense? If not, do you have suggestions?

由于尚不支持离线持久性,因此在使用Node.js时,我应该考虑使用另一个数据库来帮助您本地缓存数据

Because there is no support for offline persistence yet, I should consider using another database that can help you cache your data locally, when using Node.js

这篇关于Firestore是脱机模式下使用Node.JS的不错选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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