Thursday, October 12, 2017

Cron Job

  1. Create a cron.yaml
  2. Write Code
cron:
- description: Update Today Flight job
  url: /api/Flight/UpdateTodayFlights/KUL

  schedule: every day 02:00
  1. cd yamlfilepath
  2. gcloud app deploy cron.yaml

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.