Showing posts with label Firebase. Show all posts
Showing posts with label Firebase. Show all posts

Thursday, October 12, 2017

Firebase Realtime DB vs Firestore


  • Firestore has better querying and more structured data
    • document-model database 
      • store data in Documents, organized into Collection
      • Each document contain a set of key-value pairs.
      • Documents can contain sub collections and nested objects.
    • Search multiple field.
  • Realtime DB better latency
Pricing Model
  • Realtime DB = amount of downloaded and store on DB.
  • Firestore DB = number of reads or write.
  • Traditional App, Request large of data > Firestore
  • Many updates in second > Realtime

Firestore Data Model

  • Similar to JSON
  • Document is record, map value with name
  • name of document is unique (add() will automatically)

Monday, October 9, 2017

Firebase C#

private FirebaseClient Auth()
{
    var firebaseClient = new FirebaseClient(_URL,
        new FirebaseOptions
        {
            AuthTokenAsyncFactory = () => Task.FromResult(_FireBaseApiKey)
        });

    return firebaseClient;
}

public async Task<Dictionary<string, T>> ListLimitLast<T>(string table, string filterKey, string filterValue, int limitLast)
 {
     var firebase = Auth();

     var result = await firebase
         .Child(_Database)
         .Child(table)
         .OrderBy("DriverStaff/UserName")
         .EqualTo(filterValue)
         .LimitToLast(limitLast)
         .OnceSingleAsync<Dictionary<string, T>>();

     return result;

 }

use dictionary because ID is parent, object is child.

Monday, September 11, 2017

Firebase Cloud Function

  • Function for Fire base features (trigger event by firebase)
    • in GCP, not your mobile (light for your mobile app)
    • Logic Centralized , safe, server less
  • Example
    • Write Realtime Database trigger function
    • Upload your storage bucket
    • New user authentication
    • Incoming HTTPS requests
    • Send Message
  1. Install Node.JS
  2. Install Firebase CLI
    • npm install -g firebase-tools
  3. cd to folder (firebase cloud function project)
  4. firebase login
  5. firebase init (Deselect Database and Hosting)

https://www.youtube.com/watch?v=EvV9Vk9iOCQ#t=314.64541