mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
draft app database model
This commit is contained in:
parent
4191227db4
commit
8aa5474c20
2 changed files with 64 additions and 12 deletions
43
src/app/database.rs
Normal file
43
src/app/database.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
pub struct Database {
|
||||
connection: Arc<sqlite::Connection>,
|
||||
// Autostart migrate feature on app and db versions mismatch
|
||||
version: String,
|
||||
}
|
||||
|
||||
impl Database {
|
||||
// Construct new application DB
|
||||
pub fn init(connection: Arc<sqlite::Connection>, version: &str) -> Database {
|
||||
// Create app table if not exist yet
|
||||
/*
|
||||
connection
|
||||
.execute(
|
||||
r"
|
||||
CREATE TABLE IF NOT EXISTS `app`
|
||||
(
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`time` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`version` VARCHAR NOT NULL
|
||||
)
|
||||
",
|
||||
)
|
||||
.unwrap(); // @TODO handle errors */
|
||||
|
||||
// Return struct
|
||||
Self {
|
||||
connection,
|
||||
version: String::from(version),
|
||||
}
|
||||
}
|
||||
|
||||
// Restore previous browser session from DB
|
||||
pub fn restore(&self) {
|
||||
// @TODO migration test
|
||||
}
|
||||
|
||||
// Save browser session to DB
|
||||
pub fn save(&self) {
|
||||
// @TODO migration test
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue