如何在Firebase数据库中分离测试和生产数据? [英] How can I separate testing and production data in my Firebase Database?

查看:118
本文介绍了如何在Firebase数据库中分离测试和生产数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个Firebase项目仅包含一个用于数据的JSON树。最佳实践要求测试应在与生产数据不同的数据库上运行。实现这一目标的最简单方法是什么?

Each Firebase project includes only one JSON tree for data. Best practices dictate that tests should be run on a separate database from production data. What is the simplest way to achieve this?

我考虑过的一些事情:


  • 在同一个项目中使用多个子树进行测试和生产 - 这看起来很混乱,测试和生产数据几乎没有分开。

  • 设置多个Firebase项目进行测试和生产 - 这个似乎是这个问题的最佳答案与Android相关。但我不确定如何在Xcode中设置多个 GoogleService-Info.plist 文件,并根据我的应用配置在它们之间切换。

  • Using multiple sub-trees within the same project for testing and production - This seems messy and the testing and production data are hardly separated.
  • Setting up multiple Firebase projects for testing and production - This seems like the best answer from this question related to Android. But I'm not sure how to set up multiple GoogleService-Info.plist files in Xcode and switch between them based on my app's Configuration.

推荐答案

创建多个Firebase项目。每个项目都有自己的plist文件。

Create multiple Firebase projects. Each project has its own plist file.

FIRApp 有一个自定义配置选项。下载测试/调试项目的plist,重命名并加载如下。

FIRApp has a custom configuration option. Download the plist for your testing/debug project, rename it and load like below.

#if DEBUG
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-dev" ofType:@"plist"];
    FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
    [FIRApp configureWithOptions:options];
#else
    [FIRApp configure];
#endif

可以找到更详细的解释这里

A more detailed explanation can be found here

这篇关于如何在Firebase数据库中分离测试和生产数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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