#data-store #serialization #api #google-api #google #web

bin+lib ddb

Datastore DB - High Level Rust API (with serde support)

6 releases

0.0.6 Oct 23, 2019
0.0.5 Oct 2, 2019
0.0.1 Sep 30, 2019

#91 in #data-store

MIT license

32KB
699 lines

Datastore DB

Googles Cloud Firestore in Datastore mode - High Level Rust API (with serde support!)

API Preview

// MODEL
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TodoItem {
    pub name: String,
    pub title: String,
}
// MODEL METADATA
impl EntityKey for TodoItem {
    fn entity_kind_key() -> String {
        String::from("TodoItem")
    }
    fn entity_name_key(&self) -> String {
        self.name.clone()
    }
}
// INIT
let db = DatastoreClient::new().unwrap();
let item = TodoItem {
    name: String::from("test"),
    title: String::from("lorem ipsum")
};
// GO!
db.upsert(item);

lib.rs:

use serde::{Serialize, Deserialize};

// MODEL
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TodoItem {
    pub name: String,
    pub title: String,
}
// MODEL METADATA
impl ddb::EntityKey for TodoItem {
    fn entity_kind_key() -> String {
        String::from("TodoItem")
    }
    fn entity_name_key(&self) -> String {
        self.name.clone()
    }
}
// INIT
let db = ddb::DatastoreClient::new().unwrap();
let item = TodoItem {
    name: String::from("test"),
    title: String::from("lorem ipsum")
};
// GO!
db.upsert(item);

Dependencies

~27–40MB
~798K SLoC