Crate datastore_mysql
source · [−]Expand description
datastore-mysql
This crate provides MySqlStore
which is a Store
implementation using the MySQL
database.
MySqlStore
supports these types:
bool
i8
,i16
,i32
,i64
u8
,u16
,u32
,u64
f32
,f64
&str
,String
&[u8]
,Vec<u8>
Examples
ⓘ
use datastore::{Store, StoreExt, StoreData};
use datastore_mysql::MySqlStore;
#[derive(Debug, StoreData)]
pub struct Person {
id: i64,
name: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = MySqlStore::connect("mysql://user:password@host/database").await?;
let person = Person {
id: 1,
name: String::from("Robb"),
};
store.insert(store.descriptor::<Person>(), person).await?;
let persons: Vec<Person> = store.get_all(store.descriptor::<Person>()).await?;
println!("{:?}", persons);
Ok(())
}
Structs
A pooled
Store
for the MySQL database.