Working with Firebase in development and production databases - database

I'm starting a new project using Firebase as my database to store the data of my application. Let's say, I finish my app and it's deployed in the app stores, so real users are using my app and they are entering new data to my Firebase database, what happens If I want to add a new functionality to my app, obviusly I cannot use the database that are using my real users, so I create a new Firebase project called myapp-dev, I import the data from my production database and I work in there, I added new data and new inserts/updates that will modify the structure of my production database, is there a way that I can combine the 2 databases dev into prod to not generate conflicts???

The Firebase team recommends using two different projects to isolate different working environments. It's not advised to combine them into a single project.

Related

How to understand data storage for a React app?

I am learning web dev and I am planning on developing a simple web app using React: a decision matrix tool. 
I need users to be able log in and save their matrices under their profile so I prefer to not use LocalStorage and thus learn more about databases. I am thinking of using JSON as the data format and I will also need to store basics user data for login and their profile.

I wonder how to tackle such a project since so far I have only been using GitHub Pages to host my static websites. Most of what I find by googling seems confusing or irrelevant for such a small-sized project.

My questions are:
What is the simplest way to store, access and edit JSON data as well as user data for a web app?
Are there any simple databases that can be “hosted” together with the app files on a server? Not sure if the question makes sense but I don’t understand where the database is.
What article or resource would you recommend to understand the concepts for data storage?
Ideally you would want to create a backend server using any language/framework e.g nodejs, java, django, php etc and expose the required data through APIs. But, if you don't want to create a separate backend app you can use Firebase database Firestore to save and fetch all of your required data. You can even use firebase hosting to deploy your app. Moreover, firebase also have their Authentication service which you can leverage for your app's authentication.

Tips on approaching a flutter app which uses website data and features

I am new to app development and I am thinking about creating an app which will store all the anime that you are currently watching or have watched in the past. The purpose of this app is to store your progress of an anime/manga so that if you forget which chapter you were on the last time you watched/read the anime or manga.
My plan is to connect this app to myanimelist website and use its feature on my app to find an anime. Then if the user adds the anime to his watch-list then it will store the important data e.g., name, description, author, Image.
I am totally new to app development and I have to create an app for the final year project. As on how to start the app or the resources required I am at loss.
The main topic of my concern is on how I should handle the use of website data or the connection to the database. Is something like using SQL queries? Which database should I use to store the data on local device?
Any help is appreciated.
Your questions
how I should handle the use of website data or the connection to the database.
if You have an API that you are using for your website, then you can use that API to fetch data in your flutter app.In case your don't have an API you have to create one for your app.
Which database should I use to store the data on the local device?
For storing data to the local device you can use sqflite package for flutter to store data. Using sqflite you can write simple SQL queries to fetch or store data in the
database.
Ask if you have any problems.

Electron - How to persist offline data and sync between different app installation

According to this answer, I want to use an offline first db inside my electron app. I nedd that the users are not able to directly modify the database, but they can only read data using the UI. The data needs to be synced with a master remote client app that will add and modify data. Can anyone suggest me a good database library to do this?I have a pusher account and an heroku one, that can be used to pass the data between the clients, but first I need a way to store them into the app

Do I need other libraries than React.js to work with databases

I just started learning react. Now I want to build a small application where:
A user can Register/Log In (working with database)
The user can add items to a todo list
The todo list is stored in a database
Do I need other libraries to work with databases?
It's a small application.
Should I use Redux or rather something using MVC pattern like ASP.net?
I don't have any expierence with any of these. After lot of research I am still clueless on where to start with.
As you are a beginner. I would recommend you to use below libraries in both front-end and backend to start with your application
Front-end:
React - works as view layer
axios - to talk to backend database for all CRUD operations
Use localstorage or session storage to work between components. Because your application is very small so you can go with this approach or consider
using redux from now if you feel your application will grow bigger in
future
Back-end:
Keep your back end service as micro-services
As you are already working on react means you know something about javascript so I recommend you write your backend service in nodejs
If you want to use No SQL database then you can go with mongoDB database using mongoose in nodejs
If you prefer SQL database then I would recommend you to start with Postgres SQL database. Postgres SQL is popular these days than
any other SQL database
These are the required libraries for you to start.
I would recommend you to go for MERN stack i.e., MongoDB, Express JS, ReactJS and NodeJS

How to create multi environment DB's with Firestore

I've been looking at how to create multiple Firestore instances in Firebase, I need different Db's for prod, staging and development. I read the documentation and seems that I only need to modify the "Google-services.json" file in the applications. what I don't get is what should I modify and how that would look in the console.
Am I going to see different instances in the same project?
I need to create different projects for every environment and modify those values in the file?
If I need to test something that requires testing in all environments and all of them require Blaze to run that test do I have
to pay Triple?
Thanks in advance
Firebase doesn't support the use of multiple Firestore instances in a single project.
The Firebase team strongly recommends creating different projects for each of your environments to keep them separate. This probably means you will have to build different apps that each point to different instances, or you will have to somehow configure your app at runtime to select which project you want to work with.
There is no obligation to add billing to any of the projects you don't want to pay for, as long as you accept the limitations of the Spark plan.
Yes Firebase doesn't support multiple instance in a single project. However my case, i created 3 different document in Firestore root and setup each environment to refer these documents accordingly. Each document will have the same collections, sub collections and documents.
For example,
dev -> users -> details
-> others_collection -> details
stag -> users
-> others_collection -> details
prod -> users
-> others_collection -> details
On the client side, each environment will get the collection like this :
db.collection(`${env}/users`)
I am doing this on small project and seem pretty happy with what Firestore provided. In single project. i can create many ios/android apps according to the environment and each environment have it own document and collections in Firestore.
The safest way is to create a new google cloud project. You can export your current firestore database to your new project if needed.
Step by step:
Backup your current database by exporting all your documents into a
bucket:
https://firebase.google.com/docs/firestore/manage-data/export-import
gcloud beta firestore export gs://[BUCKET_NAME]
Create a new project -> https://cloud.google.com/resource-manager/docs/creating-managing-projects
In the dashboard, select Firestore into your new project and create an empty database
In the dashboard, go to your BACKUP_BUCKET and add your new project service account in the permission tab
Switch project to your new project
gcloud config set project 'new-project'
Then export your data
gcloud beta firestore import gs://[BUCKET_NAME]/[EXPORT_PREFIX]/ The EXPORT_PREFIX being the name of the folder created in your bucket.
I use this method to have clearly separated 'preprod' and 'production' environments (the team can access and synchronize with production without having access to the production environment codebase and configuration).

Resources