#firebase #real-time #web-api #database #api-wrapper #service

firebase_realtime_database

A web API wrapper for the firebase realtime database

16 releases

0.3.1 Jul 23, 2023
0.3.0 Jul 23, 2023
0.2.12 Jul 30, 2022
0.1.9 Jul 28, 2022
0.1.5 May 15, 2022

#1746 in Web programming

Download history 16/week @ 2024-02-19 5/week @ 2024-02-26 6/week @ 2024-03-11 278/week @ 2024-04-01

284 downloads per month

MIT license

9KB
171 lines

Firebase Realtime Database Wrapper

A basic abstraction over the Firebase Web API.

To begin, create a Database struct by passing the path to your service account token file, and your project id"

use firebase_realtime_database::Database;

let database = Database::from_path("project-id", "path/to/token/file.json").await?;

The database exposes four methods to interact with the database

let get_result = database.get("users/tom").await?;

let put_result = database
    .put(
        "users/joe",
        &HashMap::from([("first_name", "Joe"), ("last_name", "Mama")]),
    )
    .await?;

let update_result = database
    .update("users/joe", &HashMap::from([("last_name", "Ma'ma")]))
    .await?;

let delete_result = database.delete("users/joe2").await?;

Where each method takes a path. Put, Update and Delete take in Serializable data. All methods return a result of reqwest::Response and FirebaseError. FirebaseError contains just a message field that contains the error message.

Dependencies

~18–33MB
~633K SLoC