mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
normalize tab items component
This commit is contained in:
parent
47e2bc4617
commit
65502c247d
29 changed files with 427 additions and 117 deletions
|
|
@ -3,7 +3,6 @@ use sqlite::{Error, Transaction};
|
|||
pub struct Table {
|
||||
pub id: i64,
|
||||
// pub app_browser_window_id: i64, not in use
|
||||
pub is_current: bool,
|
||||
}
|
||||
|
||||
pub struct Database {
|
||||
|
|
@ -16,40 +15,32 @@ impl Database {
|
|||
"CREATE TABLE IF NOT EXISTS `app_browser_window_tab`
|
||||
(
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`app_browser_window_id` INTEGER NOT NULL,
|
||||
`is_current` INTEGER NOT NULL
|
||||
`app_browser_window_id` INTEGER NOT NULL
|
||||
)",
|
||||
[],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn add(
|
||||
tx: &Transaction,
|
||||
app_browser_window_id: &i64,
|
||||
is_current: &bool,
|
||||
) -> Result<usize, Error> {
|
||||
pub fn add(tx: &Transaction, app_browser_window_id: &i64) -> Result<usize, Error> {
|
||||
tx.execute(
|
||||
"INSERT INTO `app_browser_window_tab` (
|
||||
`app_browser_window_id`,
|
||||
`is_current`
|
||||
) VALUES (?,?)",
|
||||
[app_browser_window_id, &(*is_current as i64)],
|
||||
`app_browser_window_id`
|
||||
) VALUES (?)",
|
||||
[app_browser_window_id],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn records(tx: &Transaction, app_browser_window_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
let mut stmt = tx.prepare(
|
||||
"SELECT `id`,
|
||||
`app_browser_window_id`,
|
||||
`is_current` FROM `app_browser_window_tab`
|
||||
WHERE `app_browser_window_id` = ?",
|
||||
`app_browser_window_id` FROM `app_browser_window_tab`
|
||||
WHERE `app_browser_window_id` = ?",
|
||||
)?;
|
||||
|
||||
let result = stmt.query_map([app_browser_window_id], |row| {
|
||||
Ok(Table {
|
||||
id: row.get(0)?,
|
||||
// app_browser_window_id: row.get(1)?, not in use
|
||||
is_current: row.get(2)?,
|
||||
})
|
||||
})?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue