📕
TIC
  • Tehnologii ale Informaţiei şi Comunicaţiilor (TIC)
  • Basic web principles
    • How web pages work
    • The pillars of a web page
    • Extra: Getting Started with GitHub
  • Basic HTML
    • Description and Basic Syntax
    • Extra resources
  • Basic CSS
    • Description and Basic Syntax
    • Advanced Positioning
    • Extra Resources
  • Basic Javascript
    • Description and basic syntax
    • The Document Object Model
    • Extra Resources
    • Basic assignment
    • The Color Game
  • Advanced Javascript
    • Runtime Engine, Callstack, Scope
    • ES6
  • Advanced Javascript 2
  • Programming paradigms
  • OOP Javascript
  • Functional Programming
  • OOP vs. Functional Programming
  • Asynchronous Javascript
  • Backend Javascript
    • NodeJS
    • ExpressJS
    • REST APIs
    • Authentication and Authorization
  • Firebase
    • NoSQL Databases
    • Database as a Service
    • Google Cloud Firestore
    • CRUD operations
    • Securing your database
  • Basic VueJS
  • Agenda: VueJS and Frontend Frameworks
  • Single Page Applications
  • VueJS basic syntax
  • Vue Components
  • Advanced VueJS
  • Advanced apps with Vue CLI
  • Vue Router
  • SPA State Management - Vuex
  • Composition API
  • Evaluation
    • Final Individual assignment
Powered by GitBook
On this page
  • Google Firebase
  • Quick guide

Was this helpful?

  1. Firebase

Google Cloud Firestore

PreviousDatabase as a ServiceNextCRUD operations

Last updated 7 months ago

Was this helpful?

Google Firebase

Google Firebase is a set of services and hosting tools for creating serverless applications (be it web or mobile) including a real-time NoSQL database as a service, services for authentication, storing files, various analytics, and serverless functions (private business logic). It removes the need to deploy and maintain one or multiple servers for these types of features, thus letting the focus be on the client application rather than also dealing with scaling, securing, and keeping the latest software for a server.

It is a very popular, cost-effective (free of charge for low usage) method to start a real-life web or mobile product. You can find more at:

Cloud Firestore is a NoSQL, document-oriented database as a service. You store data in JSON documents, which are organized into collections.

Each document contains a set of key-value pairs. Cloud Firestore is optimized for storing large collections of small documents.

All documents must be stored in collections. Documents can contain subcollections and nested objects, both of which can include primitive fields like strings or complex objects like lists.

Quick guide

Then, you'll need to create a project which will have access to the tools provided by the Firebase suite. For this project, you have to create a database. The option is available in the project's menu and doesn't require any sort of setup.

Access to a Firestore database, in a Node.js app is done through an admin SDK which is installed by running the following command:

npm install firebase-admin --save

To use the Firebase Admin SDK on your own server (or any other Node.js environment), use a service account. Go to IAM & admin > Service accounts in the Cloud Platform Console. Generate a new private key and save the JSON file. Then use the file to initialize the SDK:

var admin = require("firebase-admin");

var serviceAccount = require("'./path/to/serviceAccountKey.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});

db = admin.firestore()

The credentials are generated from the Google Firebase Console, in the settings section of a project, at the Service Accounts tab.

The JSON file should look like this:

{
  "type": "service_account",
  "project_id": "tic-ebusiness",
  "private_key_id": "3caa73f61878857f29222b68dc66c773a28758cb",
  "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEv...7TpScpl+g=\n-----END PRIVATE KEY-----\n",
  "client_email": "firebase-adminsdk-x0oa8@tic-ebusiness.iam.gserviceaccount.com",
  "client_id": "1034...3350",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-x0oa8%40tic-ebusiness.iam.gserviceaccount.com"
}

As an alternative, you can also read about:

or less popular (this is an SQL DB as a service)

First of all, you need to set up a Google Firebase account at:

https://aws.amazon.com/amplify/
https://supabase.com/
https://firebase.google.com/
https://firebase.google.com/
Firebase in 100 seconds