Skip to main content

Golang - MVC Pattern API Interactions with Firebase Database


Firebase Database interactions from Go:

API. Developers can use this API to access the Firebase database from Go applications. It support realtime event listeners yet, but supports all the data update and query capabilities a typical server-side application would need. Listing shows how to initialize a Firebase app in Go, and store a value in the database.

Store and sync data in Firebase with Golang :


The Firebase Real time Database, by definition, is a cloud-hosted database. This Firebase NoSQL cloud database is trending as the new go-to data storage concept. With this, data is stored as JSON, and not in the traditional format. Also, Firebase performs real time data synchronisation to every client that is connected.

How does it work?

The Firebase Real time Database lets you build rich, collaborative applications by allowing secure access to the database directly from Server-side code.

Since I am describing how to implement a client of Firebase with Golang, first, we need to install the GoogleFirebase package  Below are the steps:


Installation :

Step 1: Install Golang in ubuntu.
https://manishpaneri.blogspot.com/2018/03/how-to-install-go-19-on-ubuntu.html

Step 2: Extract GoogleFirebase Package.
Now extract the downloaded archive and install it to the golang src folder location on the system.
wget https://github.com/ManishPaneri/GoogleFirebase/archive/master.zip
$ tar -xvf master.zip ~/go_Projects/src/.

Step 3: Google Firebase Env Variable Set.
$ export GOOGLE_APPLICATION_CREDENTIALS="firebaseJson.json"

Step 4: Application Setup Set.
$ vi conf/env.yml projectid: firebaseJson
Step 4: Run Application
$ cd ~/go_projects/src/GoogleFirebase/
$ go run main.go
Now application working on 9000 port.

Comments

Popular posts from this blog

Java Currency Formatter Solution

Given a  double-precision  number,  , denoting an amount of money, use the  NumberFormat  class'  getCurrencyInstance  method to convert   into the US, Indian, Chinese, and French currency formats. Then print the formatted values as follows: US: formattedPayment India: formattedPayment China: formattedPayment France: formattedPayment where   is   formatted according to the appropriate  Locale 's currency. Note:  India does not have a built-in Locale, so you must  construct one  where the language is  en  (i.e., English). Input Format A single double-precision number denoting  . Constraints Output Format On the first line, print  US: u  where   is   formatted for US currency.  On the second line, print  India: i  where   is   formatted for Indian currency.  On the third line...

Java Stdin and Stdout II Code

In this challenge, you must read an  integer , a  double , and a  String  from stdin, then print the values according to the instructions in the  Output Format  section below. To make the problem a little easier, a portion of the code is provided for you in the editor. Note:  We recommend completing  Java Stdin and Stdout I  before attempting this challenge. Input Format There are three lines of input: The first line contains an  integer . The second line contains a  double . The third line contains a  String . Output Format There are three lines of output: On the first line, print  String:  followed by the unaltered  String  read from stdin. On the second line, print  Double:  followed by the unaltered  double  read from stdin. On the third line, print  Int:  followed by the unaltered  integer  read from stdin. To make the pr...

How to Unirest HTTP API Requests Call in Java

Unirest is a set of lightweight HTTP libraries available in multiple languages, built and maintained by Mashape, who also maintain the open-source API Gateway Kong. Do yourself a favor, and start making HTTP requests like this: Creating Function : /** * Unirest API call return jsonResponse handle * Function Name: ApiCallFunction * @param vEmail, Url * @return status */ public static String ApiCallFunction(String vEmail, String Url) { try{ HttpResponse<JsonNode> jsonResponse = Unirest.post(Url) .field("vEmail",vEmail) .asJson(); JSONObject output= jsonResponse.getBody().getObject(); String status= output.getString("status"); return status; }catch(UnirestException e){ return "error"; } } Type Of   Response Handle : // Response to String Sting bookResponse = Unirest.get(Url).asString(); //Respo...