...
This commit is contained in:
parent
bcfa874c2b
commit
04233e6f1a
@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
A database library built on top of sled with model support.
|
A database library built on top of sled with model support.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## example
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run --bin dbexample2
|
||||||
|
```
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Type-safe database operations
|
- Type-safe database operations
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cargo test zaz::tests -- --test-threads=1
|
|
||||||
```
|
|
@ -1,6 +1,6 @@
|
|||||||
use chrono::{DateTime, Utc, Duration};
|
use chrono::{DateTime, Utc, Duration};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use crate::core::{SledModel, Storable}; // Import Sled traits from new location
|
use crate::db::base::{SledModel, Storable}; // Import Sled traits from db module
|
||||||
|
|
||||||
/// Currency represents a monetary value with amount and currency code
|
/// Currency represents a monetary value with amount and currency code
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@ -54,3 +54,18 @@ impl CurrencyBuilder {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implement Storable trait (provides default dump/load)
|
||||||
|
impl Storable for Currency {}
|
||||||
|
|
||||||
|
// Implement SledModel trait
|
||||||
|
impl SledModel for Currency {
|
||||||
|
fn get_id(&self) -> String {
|
||||||
|
// Use the currency code as the ID
|
||||||
|
self.currency_code.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn db_prefix() -> &'static str {
|
||||||
|
"currency"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use chrono::{DateTime, Utc, Duration};
|
use chrono::{DateTime, Utc, Duration};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use crate::core::{SledModel, Storable}; // Import Sled traits from new location
|
use crate::db::base::{SledModel, Storable}; // Import Sled traits from db module
|
||||||
|
|
||||||
|
|
||||||
/// ProductType represents the type of a product
|
/// ProductType represents the type of a product
|
||||||
@ -355,4 +355,4 @@ impl SledModel for Product {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Import Currency from the currency module
|
// Import Currency from the currency module
|
||||||
use super::Currency;
|
use crate::models::biz::Currency;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use super::product::Currency; // Use super:: for sibling module
|
use crate::models::biz::Currency; // Use crate:: for importing from the module
|
||||||
use crate::core::{SledModel, Storable}; // Import Sled traits from new location
|
use crate::db::base::{SledModel, Storable}; // Import Sled traits from db module
|
||||||
// use super::db::Model; // Removed old Model trait import
|
// use super::db::Model; // Removed old Model trait import
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
4
herodb/tmp/dbexample2/currency/conf
Normal file
4
herodb/tmp/dbexample2/currency/conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
segment_size: 524288
|
||||||
|
use_compression: false
|
||||||
|
version: 0.34
|
||||||
|
vQÁ
|
BIN
herodb/tmp/dbexample2/currency/db
Normal file
BIN
herodb/tmp/dbexample2/currency/db
Normal file
Binary file not shown.
4
herodb/tmp/dbexample2/product/conf
Normal file
4
herodb/tmp/dbexample2/product/conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
segment_size: 524288
|
||||||
|
use_compression: false
|
||||||
|
version: 0.34
|
||||||
|
vQÁ
|
BIN
herodb/tmp/dbexample2/product/db
Normal file
BIN
herodb/tmp/dbexample2/product/db
Normal file
Binary file not shown.
4
herodb/tmp/dbexample2/sale/conf
Normal file
4
herodb/tmp/dbexample2/sale/conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
segment_size: 524288
|
||||||
|
use_compression: false
|
||||||
|
version: 0.34
|
||||||
|
vQÁ
|
BIN
herodb/tmp/dbexample2/sale/db
Normal file
BIN
herodb/tmp/dbexample2/sale/db
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user