adding a lot more funcitonality to core library
This commit is contained in:
parent
ba51c56169
commit
3c87385895
7 changed files with 378 additions and 105 deletions
|
@ -50,23 +50,25 @@ impl<T> Default for Model<T> {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
items: vec![],
|
||||
db: {
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let mut data = dirs::data_local_dir().unwrap();
|
||||
data.push("lumina");
|
||||
data.push("library-db.sqlite3");
|
||||
let mut db_url = String::from("sqlite://");
|
||||
db_url.push_str(data.to_str().unwrap());
|
||||
rt.block_on(async {
|
||||
SqliteConnection::connect(&db_url)
|
||||
.await
|
||||
.expect("problems")
|
||||
})
|
||||
},
|
||||
db: get_db(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_db() -> SqliteConnection {
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let mut data = dirs::data_local_dir().unwrap();
|
||||
data.push("lumina");
|
||||
data.push("library-db.sqlite3");
|
||||
let mut db_url = String::from("sqlite://");
|
||||
db_url.push_str(data.to_str().unwrap());
|
||||
rt.block_on(async {
|
||||
SqliteConnection::connect(&db_url)
|
||||
.await
|
||||
.expect("problems")
|
||||
})
|
||||
}
|
||||
|
||||
pub trait Modeling {
|
||||
type Item;
|
||||
|
||||
|
@ -86,5 +88,4 @@ pub trait Modeling {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
}
|
||||
mod test {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue