Giter VIP home page Giter VIP logo

firebase-rs's Introduction

firebase-rs

Crates.io docs.rs License

Rust based Firebase library.

firebase

Full Documentation

Documentation

Features

How to use

Load library

use firebase_rs::*;

Without Auth

let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap();

With Auth

let firebase = Firebase::auth("https://myfirebase.firebaseio.com", "AUTH_KEY").unwrap();

At usage for nested objects

let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users").at("USER_ID").at(...);

Read Data as Stream

With Real Time Events

let firebase = Firebase::new("https://myfirebase.firebaseio.com").at("users").unwrap();
let stream = firebase.with_realtime_events().unwrap();
stream
.listen( | event_type, data| {
println ! ("Type: {:?} Data: {:?}", event_type, data);
}, | err| println!("{:?}", err), false).await;

Read Data

Read data as string

let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users");
let users = firebase.get_as_string().await;

Read data with generic type (All)

#[derive(Serialize, Deserialize, Debug)]
struct User {
    name: String
}

let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users");
let user = firebase.get::<HashMap<String, User> > ().await;

Read data with generic type (Single record)

#[derive(Serialize, Deserialize, Debug)]
struct User {
    name: String
}

let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users").at("USER_ID");
let user = firebase.get::<User>().await;

Set Data

#[derive(Serialize, Deserialize, Debug)]
struct User {
    name: String
}

let user = User { name: String::default () };
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users");
firebase.set( & user).await;

Update Data

#[derive(Serialize, Deserialize, Debug)]
struct User {
    name: String
}

let user = User { name: String::default () };
let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().at("users").at("USER_ID");
firebase.update( & user).await;

With Params

let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap().with_params().start_at(1).order_by("name").equal_to(5).finish();
let result = firebase.get().await;

Contributors

Thanks goes to these wonderful people ✨

firebase-rs's People

Contributors

alimkoca avatar ameijboom avatar dependabot[bot] avatar dorfsmay avatar druskus20 avatar emreyalvac avatar endlessreform avatar flejz avatar themoriarty avatar wicpar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

firebase-rs's Issues

Help Me!

Hi emreyalvac:
I read your blog——https://emreyalvac.com/rust-prodecural-macros/ .
I typed source code.
The Procedural Macros complied ok.
But when I used it.

use derive_macro::*;
#[derive(Debug, SerializeMacro)]
#[TableName = "lookup"]
pub struct Lookup {
    // pub lookup_id: Uuid,
    pub lookup_description: Option<String>,
    pub lookup_name: Option<String>,
    pub lookup_type: Option<String>,
    pub lookup_value: Option<String>,
}

fn main(){
    let lookup = Lookup {lookup_description:Some("des".to_string()),lookup_name:Some("name".to_string()),lookup_type:Some("type".to_string()),lookup_value:Some("value".to_string())};
    let query = lookup.serialize_to_query();
}

error[E0405]: cannot find trait TSerializeMacro in this scope
--> src/main.rs:32:17
|
32 | #[derive(Debug, SerializeMacro)]
| ^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in the derive macro SerializeMacro (in Nightly builds, run with -Z macro-backtrace for more info)

Error module is private

It seems like firebase_rs::errors is a private module. But why return all those errors if you can't even match the enum to check which error it is?

AUTH_KEY

Hi guys, how can I find AUTH_KEY in my firebase console?
thanks

WIP

WIP

  • Doc test syntax

Cannot add multiple params

Shouldn't this set_query

for (k, v) in self.params.iter() {
self.uri.set_query(Some(format!("{}={}", k, v).as_str()));

…be something like the following?

    self.uri.query_pairs_mut().append_pair(k, v);

As it is now, if I add multiple parameters, like this:

.with_params()
.limit_to_first(50)
.start_at(1674526969)
.order_by("\"txid\"")
.finish()

Only the last one of them gets added to the URL.

Examples

Is there an example for using firebase-rs? am stumbling, in particular to how to connect to firebase.
I am new to firebase

use Async/Await syntax

It would help with programs that already have async await and want to parallelise this.
I can put in a PR when I find the time.

unwrap()

Hi,

Thanks for working on this. It's really great to have this functionality working out of the box with a lib from crates.io. I am integrating it into my server, but I have an issue. I think there are too many unwraps in the library and it doesn't seem I can avoid them.

get_generic unwraps and sometimes I don't know if the path exists and I don't want it to unwrap, I just want an error.

Do you accept PRs to make these as result instead?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.