如何防止Firebase Firestore模拟器在退出时清除数据库?

时间:2019-10-27 09:12:46

标签: firebase google-cloud-firestore

我打算使用Firebase-Firestore模拟器来处理来自Websocket的大量数据。

我只需要实时在本地处理数据。

Firestore Emulator是一个不错的选择,因为它具有我需要的所有功能。但是问题在于,每次关闭模拟器时,都会清除数据库。有没有可以更改此行为的配置或设置?

如果不可能的话。有人可以告诉我其他在本地使用Firestore的方法吗?或我可以在本地使用的任何其他替代Firebase。

2 个答案:

答案 0 :(得分:6)

使用Firebase Emulator的最新更新,您可以在模拟器运行时使用导出数据,并在再次启动时使用导入数据。

要导出数据

price_filter = request.GET.get('price_filter')

if price_filter not in ["1", "2"]:
    q = request.GET.get("q")
    # rest of the code
elif price_filter == "1":
    # more code
elif price_filter == "2":
    # more code

启动和导入模拟器

firebase emulators:export <export-directory>

答案 1 :(得分:1)

当前,您需要在每次运行模拟器时编写代码来填充数据库。

如果您希望看到其他行为,请file an issue on GitHub