Firestore 是在离线模式下使用 Node.JS 的好选择吗?

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

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

离线再在线时,我看到我对数据库的所有请求都已排队,然后推送到 Cloud Firestore。

这是我的问题:

提前感谢您的帮助!

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

根据有关 Firestore offline persistence 的官方文档:

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.

  • 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 时,还不支持离线持久化。

Where are the requests are saved?

Cloud Firestore 数据库客户端会在内存中保留您正在收听的所有数据的副本。如果启用离线持久化,客户端也会将活动和最近的数据持久化到磁盘。

What is the limit of the queue?

请检查我在这个 .

中的回答

Does that queue is configurable?

不,不是。要么全是数据库,要么什么都不是。

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 以及网络(实验性)。

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

不,我不知道。你应该问 Firebase 团队。

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

因为还没有离线持久化的支持,我应该考虑使用另一个数据库来帮助你在本地缓存你的数据,当使用Node.js