Crates.io | deta-sdk |
lib.rs | deta-sdk |
version | 0.1.2 |
source | src |
created_at | 2023-08-30 08:38:42.560618 |
updated_at | 2023-08-30 08:46:27.506037 |
description | A Rust client for Deta Base |
homepage | |
repository | https://github.com/jnsougata/deta.rs |
max_upload_size | |
id | 958799 |
size | 21,117 |
Rust bindings for the Deta Base and Drive HTTP API
Cargo.toml
[dependencies]
deta-sdk = "0.1.2"
use serde;
use deta::Deta;
#[derive(serde::Serialize, serde::Deserialize)]
struct User {
key: String,
name: String,
age: u8,
}
fn main() {
let deta = Deta::new("project_key");
let base = deta.base("base_name");
let drive = deta.drive("drive_name");
let user = User {
key: "user_1".to_string(),
name: "John".to_string(),
age: 20,
};
// BASE OPERATIONS
// Insert a single item
_ = base.insert(&user).unwrap();
// Get a single item
let user = base.get("user_1").unwrap();
// Get in deserialize format
let user_d = base.get_as::<User>("user_1").unwrap();
println!("{:?}", user_d);
// ...
// DRIVE OPERATIONS
// Put a single file
_ = drive.put("hello.txt", "Hello World".as_bytes(), Some("text/plain")).unwrap();
_ = drive.delete(vec!["hello.txt"]).unwrap();
// ...
}
Methods
put
(batch max 25)
get
(single)
insert
(single)
delete
(single)
update
(with upsert)
fetch
(with pagination)
Methods
put
(single)get
(single)delete
(single)list
(with pagination