Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I separate testing and production data in my Firebase Database?

Tags:

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?

Some things I considered:

  • 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.
like image 238
pejalo Avatar asked Jun 24 '16 19:06

pejalo


People also ask

How do I avoid duplicates in Firebase?

The best way to prevent duplicate nodes in firebase realtime database or duplicate documents in firebase firestore database is to keep a check in the app itself to verify that the record to be inserted doesn't already exist in the database by querying for data using key field in where clause.

Can Firebase be used for production?

We have a lot of large customers who use Firebase in production. The main metric to be aware of are the concurrent users. Basically, how many devices are connected to the app at the same time.

How do you filter data in Firebase Realtime Database?

We can filter data in one of three ways: by child key, by key, or by value. A query starts with one of these parameters, and then must be combined with one or more of the following parameters: startAt , endAt , limitToFirst , limitToLast , or equalTo .


1 Answers

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

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

like image 140
kasajei Avatar answered Sep 21 '22 09:09

kasajei