Crates.io | firebase-db-access |
lib.rs | firebase-db-access |
version | 0.1.2 |
source | src |
created_at | 2019-01-11 06:58:52.460751 |
updated_at | 2019-01-11 07:25:24.242937 |
description | Alpha release: Rust based library for working with Firebase, currently still under heavy development. Pulled from package firebase |
homepage | |
repository | https://github.com/Micnubinub/rust-firebase |
max_upload_size | |
id | 107891 |
size | 170,203 |
Rust based library for interacting with the Firebase REST API.
API Docs can be found at here
This is a fork of the original project firebase by "David White david.white@spry-soft.com" and "Michael Eden themichaeleden@gmail.com
The APIs in this README do not document all of the APIs available! Go to the official docs for the most up to date version of the API.
Don't forget to include the library in your project:
extern crate firebase_db_access;
use firebase::Firebase;
You can currently create a simple reference to your firebase server:
let firebase = Firebase::new("https://<your-firebase>.firebaseio.com");
Or you can create an authenticated connection by supplying your auth token:
let firebase = Firebase::authed("https://<your-firebase>.firebaseio.com", "<token>");
NOTE: You must send your requests through HTTPS or Firebase will reject it. Not specifying HTTPS will also result in an error: ParseError::UrlIsNotHTTPS
Reference nested objects in your server like so:
let show = firebase.at("/shows/futurama"); // points to /shows/futurama
let episode = show.at("s10/meanwhile"); // points to /shows/futurama/s10/meanwhile
Slashes and .json extensions will be handled accordingly:
// All of the following are equivalent:
let show = firebase.at("/shows/futurama.json");
let show = firebase.at("shows/futurama/");
let show = firebase.at("/shows/futurama/");
Reading data can be done with a simple call to .get()
let response = show.get();
let description = episode.at("description");
let response = description.set("the last episode");
let episodes = firebase.at("/shows/futurama/episodes");
let response = episodes.push("The Lost Episode!");
let description = episode.at("description");
let response = description.update("the penultimate episode");
let episode = firebase.at("/shows/futurama/s10/meanwhile");
let response = episode.remove();
let episodes = firebase.at("/shows/futurama/episodes");
let top5 = episodes.order_by("\"imdb\"").limit_to_first(5).get();
The full list of supported parameters are listed here:
order_by
limit_to_first
limit_to_last
start_at
end_at
equal_to
shallow
For now JSON is sent and received as a string literal, an easier method is likely to be implemented in future versions
let json = "{ \"name\": \"David Smith\" }"
let people = firebase.at("/earth/us/indiana");
let response = episodes.push(json);