diff --git a/README.md b/README.md index 0c709c2..e5be84c 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,68 @@ [![crates.io](https://img.shields.io/crates/v/dustdata?color=EA4342&style=flat-square)](https://crates.io/crates/dustdata) # DustData - A data concurrency control storage engine to [Rustbase](https://github.com/rustbase/rustbase) Join our [community](https://discord.gg/m5ZzWPumbd) and [chat](https://discord.gg/m5ZzWPumbd) with other Rust users. # ⚠️ Warning - This is a work in progress. The API is not stable yet. # 🔗 Contribute - [Click here](./CONTRIBUTING.md) to see how to Contribute -# Dependencies - -These are dependencies that are required to use the DustData. - -- [bson](https://crates.io/crates/bson) - # How to install - Add the following to your `Cargo.toml`: ```toml [dependencies] -dustdata = "2.0.0-beta.0" +dustdata = "2.0.0-beta.1" ``` # Usage - -Initialize a DustData interface. - +Initialize a new `DustData` instance with the default configuration: ```rust -// DustData Configuration -let config = LsmConfig { - flush_threshold: 10240 // 10KB - sstable_path: PathBuf::from("./test_data"), -}; +use dustdata::DustData; -let dustdata = Lsm::new(config); +let mut dustdata = DustData::new(Default::default()).unwrap(); ``` -## Insert a data +## Inserting data into a collection ```rust -// ... -// Creating a data -let data = bson::doc! { - "name": "John Doe", - "age": 30, +#[derive(Serialize, Deserialize, Clone, Debug)] +struct User { + name: String, + age: i32, } -dustdata.insert("key", data); -``` +let collection = dustdata.collection::("users"); -## Getting a data +let user = User { + name: "Pedro".to_string(), + age: 21, +}; -```rust -// ... -let value = dustdata.get("key").unwrap().unwrap(); -println!("{:?}", value); -``` +// Creating a new transaction. +let mut transaction = collection.start(); -## Updating a data +// Inserting the user into the transaction. +transaction.insert("user:1", user); -```rust -// ... -let data = bson::doc! { - "name": "Joe Mamma", - "age": 42, -} +// Committing the transaction. +collection.commit(&mut transaction).unwrap(); -dustdata.update("key", data); +// Done! ``` -## Deleting a data +## Reading data from a collection ```rust -// ... -dustdata.delete("key"); -``` +let collection = dustdata.collection::("users").unwrap(); -# To-dos +let user = collection.get("user:1").unwrap(); +``` -- [x] Memtable (06/19/22) -- [x] SSTable (08/20/22) -- [x] Snapshots (12/16/22) # Authors diff --git a/tests/collection_tests.rs b/tests/collection_tests.rs index b1e0387..c8f0b3c 100644 --- a/tests/collection_tests.rs +++ b/tests/collection_tests.rs @@ -1,4 +1,5 @@ use dustdata::DustData; +use serde::{Deserialize, Serialize}; pub fn test_config() -> dustdata::DustDataConfig { dustdata::DustDataConfig::default()