Crates.io | harperdb |
lib.rs | harperdb |
version | 1.0.0 |
source | src |
created_at | 2020-10-20 17:03:58.523276 |
updated_at | 2020-10-20 17:31:56.414994 |
description | The Rust SDK for HarperDB |
homepage | https://harperdb.io |
repository | https://github.com/HarperDB/harperdb-sdk-rust |
max_upload_size | |
id | 303568 |
size | 120,325 |
HarperDB is a SQL/NoSQL data management platform. It is fully indexed, doesn't duplicate data, and runs on any device- from the edge to the cloud.
It is built natively as a set of micro-services, making development and integration easy and seamless. HarperDB utilizes a single-endpoint for all operations. HarperDB’s RESTful nature makes it stateless, stable, and scalable.
Dependencies:
[dependencies]
tokio = { version = "0.2", features = ["full"] }
serde_json = "1.0"
Basic usage:
use harperdb_sdk_rust::{ HarperConfig, Harper };
use harperdb_sdk_rust as harper;
use serde::{Deserialize, Serialize};
use serde_json::{Value};
use std::{error::Error};
#[macro_use]
extern crate serde_json;
#[derive(Debug, Serialize, Deserialize)]
struct DogRecord {
id: usize,
name: String,
age: Option<usize>,
breed: Option<String>,
image: Option<String>,
__createdtime__: usize,
__updatedtime__: usize,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let config: HarperConfig = HarperConfig {
url: "http://0.0.0.0:9925/",
username: "HDB_ADMIN",
password: "password",
schema: "dev",
};
let harper_client = new(config);
// Insert Record
let insert_option: harper::QueryOptions = harper::QueryOptions {
table: "dog",
schema: "dev",
records:json!([{
"id": 1,
"name": "Incredible Metal Chair",
"breed": "Mutt",
"age": 4,
"image": "http://lorempixel.com/640/480/nature"
}]),
};
let result = harper_client.insert(insert_option).await?;
// Get Query Response
println!("{:#?}", result.status());
// Query Database
let result = harper_client.query("SELECT * FROM dev.dog limit 2",).await?;
let dog_record: Vec<DogRecord> = result.json().await?;
println!("{:#?}", dog_record);
// Get result as text
// let data = result.text().await?;
// println!("{:#?}", data);
}
# Install database
docker run -d -p 9925:9925 -v <Host Directory Path>:/opt/harperdb/hdb/ harperdb/hdb
# Terrform database
./test_setup.sh
# Run Test
cargo test
# Clear Database
./test_teardown.sh