deta-sdk

Crates.iodeta-sdk
lib.rsdeta-sdk
version0.1.2
sourcesrc
created_at2023-08-30 08:38:42.560618
updated_at2023-08-30 08:46:27.506037
descriptionA Rust client for Deta Base
homepage
repositoryhttps://github.com/jnsougata/deta.rs
max_upload_size
id958799
size21,117
Sougata Jana (jnsougata)

documentation

README

deta.rs

Rust bindings for the Deta Base and Drive HTTP API

Usage

Cargo.toml

[dependencies]
deta-sdk = "0.1.2"

Quickstart

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();
    
    // ... 
    
}


Base

Methods

  • put (batch max 25)

  • get (single)

  • insert (single)

  • delete (single)

  • update (with upsert)

  • fetch (with pagination)

Drive

Methods

  • put (single)
  • get (single)
  • delete (single)
  • list (with pagination
Commit count: 59

cargo fmt