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.

No comments:

Post a Comment