mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
rename low-level db api
This commit is contained in:
parent
091b7da7b8
commit
aa076b370b
27 changed files with 70 additions and 70 deletions
|
|
@ -16,11 +16,11 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(tx: &Transaction, app_id: &i64) -> Result<usize, Error> {
|
||||
pub fn insert(tx: &Transaction, app_id: &i64) -> Result<usize, Error> {
|
||||
tx.execute("INSERT INTO `app_browser` (`app_id`) VALUES (?)", [app_id])
|
||||
}
|
||||
|
||||
pub fn records(tx: &Transaction, app_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
pub fn select(tx: &Transaction, app_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
let mut stmt = tx.prepare("SELECT `id`, `app_id` FROM `app_browser` WHERE `app_id` = ?")?;
|
||||
|
||||
let result = stmt.query_map([app_id], |row| {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ impl Widget {
|
|||
|
||||
// Actions
|
||||
pub fn clean(&self, transaction: &Transaction, app_browser_id: &i64) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_id) {
|
||||
match database::select(transaction, app_browser_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match database::delete(transaction, &record.id) {
|
||||
|
|
@ -61,7 +61,7 @@ impl Widget {
|
|||
}
|
||||
|
||||
pub fn restore(&self, transaction: &Transaction, app_browser_id: &i64) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_id) {
|
||||
match database::select(transaction, app_browser_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
// Restore widget
|
||||
|
|
@ -80,7 +80,7 @@ impl Widget {
|
|||
}
|
||||
|
||||
pub fn save(&self, transaction: &Transaction, app_browser_id: &i64) -> Result<(), String> {
|
||||
match database::add(
|
||||
match database::insert(
|
||||
transaction,
|
||||
app_browser_id,
|
||||
&self.gobject.default_width(),
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(
|
||||
pub fn insert(
|
||||
tx: &Transaction,
|
||||
app_browser_id: &i64,
|
||||
default_width: &i32,
|
||||
|
|
@ -45,7 +45,7 @@ pub fn add(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn records(tx: &Transaction, app_browser_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
pub fn select(tx: &Transaction, app_browser_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
let mut stmt = tx.prepare(
|
||||
"SELECT `id`,
|
||||
`app_browser_id`,
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ impl Window {
|
|||
}
|
||||
|
||||
pub fn clean(&self, transaction: &Transaction, app_browser_id: &i64) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_id) {
|
||||
match database::select(transaction, app_browser_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match database::delete(transaction, &record.id) {
|
||||
|
|
@ -126,7 +126,7 @@ impl Window {
|
|||
}
|
||||
|
||||
pub fn restore(&self, transaction: &Transaction, app_browser_id: &i64) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_id) {
|
||||
match database::select(transaction, app_browser_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
// Delegate restore action to childs
|
||||
|
|
@ -140,7 +140,7 @@ impl Window {
|
|||
}
|
||||
|
||||
pub fn save(&self, transaction: &Transaction, app_browser_id: &i64) -> Result<(), String> {
|
||||
match database::add(transaction, app_browser_id) {
|
||||
match database::insert(transaction, app_browser_id) {
|
||||
Ok(_) => {
|
||||
// Delegate save action to childs
|
||||
if let Err(e) = self
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(tx: &Transaction, app_browser_id: &i64) -> Result<usize, Error> {
|
||||
pub fn insert(tx: &Transaction, app_browser_id: &i64) -> Result<usize, Error> {
|
||||
tx.execute(
|
||||
"INSERT INTO `app_browser_window` (`app_browser_id`) VALUES (?)",
|
||||
[app_browser_id],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn records(tx: &Transaction, app_browser_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
pub fn select(tx: &Transaction, app_browser_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
let mut stmt = tx.prepare(
|
||||
"SELECT `id`,
|
||||
`app_browser_id` FROM `app_browser_window`
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ impl Tab {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_id) {
|
||||
match database::select(transaction, app_browser_window_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match database::delete(transaction, &record.id) {
|
||||
|
|
@ -273,7 +273,7 @@ impl Tab {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_id) {
|
||||
match database::select(transaction, app_browser_window_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match Item::restore(
|
||||
|
|
@ -306,7 +306,7 @@ impl Tab {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::add(transaction, app_browser_window_id) {
|
||||
match database::insert(transaction, app_browser_window_id) {
|
||||
Ok(_) => {
|
||||
// Delegate save action to childs
|
||||
let id = database::last_insert_id(transaction);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(tx: &Transaction, app_browser_window_id: &i64) -> Result<usize, Error> {
|
||||
pub fn insert(tx: &Transaction, app_browser_window_id: &i64) -> Result<usize, Error> {
|
||||
tx.execute(
|
||||
"INSERT INTO `app_browser_window_tab` (
|
||||
`app_browser_window_id`
|
||||
|
|
@ -25,7 +25,7 @@ pub fn add(tx: &Transaction, app_browser_window_id: &i64) -> Result<usize, Error
|
|||
)
|
||||
}
|
||||
|
||||
pub fn records(tx: &Transaction, app_browser_window_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
pub fn select(tx: &Transaction, app_browser_window_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
let mut stmt = tx.prepare(
|
||||
"SELECT `id`,
|
||||
`app_browser_window_id` FROM `app_browser_window_tab`
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ impl Item {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_id) {
|
||||
match database::select(transaction, app_browser_window_tab_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match database::delete(transaction, &record.id) {
|
||||
|
|
@ -139,7 +139,7 @@ impl Item {
|
|||
) -> Result<Vec<Rc<Item>>, String> {
|
||||
let mut items = Vec::new();
|
||||
|
||||
match database::records(transaction, app_browser_window_tab_id) {
|
||||
match database::select(transaction, app_browser_window_tab_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
// Construct new item object
|
||||
|
|
@ -182,7 +182,7 @@ impl Item {
|
|||
is_selected: &bool,
|
||||
is_attention: &bool,
|
||||
) -> Result<(), String> {
|
||||
match database::add(
|
||||
match database::insert(
|
||||
transaction,
|
||||
app_browser_window_tab_id,
|
||||
page_position,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(
|
||||
pub fn insert(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_id: &i64,
|
||||
page_position: &i32,
|
||||
|
|
@ -49,7 +49,7 @@ pub fn add(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn records(tx: &Transaction, app_browser_window_tab_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
pub fn select(tx: &Transaction, app_browser_window_tab_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
let mut stmt = tx.prepare(
|
||||
"SELECT `id`,
|
||||
`app_browser_window_tab_id`,
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ impl Page {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_item_id) {
|
||||
match database::select(transaction, app_browser_window_tab_item_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match database::delete(transaction, &record.id) {
|
||||
|
|
@ -323,7 +323,7 @@ impl Page {
|
|||
self.meta.set_status(Status::SessionRestore);
|
||||
|
||||
// Begin page restore
|
||||
match database::records(transaction, app_browser_window_tab_item_id) {
|
||||
match database::select(transaction, app_browser_window_tab_item_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
// Delegate restore action to the item childs
|
||||
|
|
@ -345,7 +345,7 @@ impl Page {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::add(transaction, app_browser_window_tab_item_id) {
|
||||
match database::insert(transaction, app_browser_window_tab_item_id) {
|
||||
Ok(_) => {
|
||||
let id = database::last_insert_id(transaction);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(tx: &Transaction, app_browser_window_tab_item_id: &i64) -> Result<usize, Error> {
|
||||
pub fn insert(tx: &Transaction, app_browser_window_tab_item_id: &i64) -> Result<usize, Error> {
|
||||
tx.execute(
|
||||
"INSERT INTO `app_browser_window_tab_item_page` (
|
||||
`app_browser_window_tab_item_id`
|
||||
|
|
@ -25,10 +25,7 @@ pub fn add(tx: &Transaction, app_browser_window_tab_item_id: &i64) -> Result<usi
|
|||
)
|
||||
}
|
||||
|
||||
pub fn records(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_id: &i64,
|
||||
) -> Result<Vec<Table>, Error> {
|
||||
pub fn select(tx: &Transaction, app_browser_window_tab_item_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
let mut stmt = tx.prepare(
|
||||
"SELECT `id`,
|
||||
`app_browser_window_tab_item_id`
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ impl Meta {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_page_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_page_id) {
|
||||
match database::select(transaction, app_browser_window_tab_page_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match database::delete(transaction, &record.id) {
|
||||
|
|
@ -134,7 +134,7 @@ impl Meta {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_page_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_page_id) {
|
||||
match database::select(transaction, app_browser_window_tab_page_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
// Record value can be stored as NULL
|
||||
|
|
@ -160,7 +160,7 @@ impl Meta {
|
|||
// Keep value in memory until operation complete
|
||||
let title = self.title();
|
||||
|
||||
match database::add(
|
||||
match database::insert(
|
||||
transaction,
|
||||
app_browser_window_tab_page_id,
|
||||
match title.is_empty() {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(
|
||||
pub fn insert(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_page_id: &i64,
|
||||
title: Option<&str>,
|
||||
|
|
@ -32,7 +32,7 @@ pub fn add(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn records(
|
||||
pub fn select(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_page_id: &i64,
|
||||
) -> Result<Vec<Table>, Error> {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ impl Navigation {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_page_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_item_page_id) {
|
||||
match database::select(transaction, app_browser_window_tab_item_page_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match database::delete(transaction, &record.id) {
|
||||
|
|
@ -97,7 +97,7 @@ impl Navigation {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_page_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_item_page_id) {
|
||||
match database::select(transaction, app_browser_window_tab_item_page_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
// Delegate restore action to the item childs
|
||||
|
|
@ -115,7 +115,7 @@ impl Navigation {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_page_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::add(transaction, app_browser_window_tab_item_page_id) {
|
||||
match database::insert(transaction, app_browser_window_tab_item_page_id) {
|
||||
Ok(_) => {
|
||||
let id = database::last_insert_id(transaction);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(tx: &Transaction, app_browser_window_tab_item_page_id: &i64) -> Result<usize, Error> {
|
||||
pub fn insert(tx: &Transaction, app_browser_window_tab_item_page_id: &i64) -> Result<usize, Error> {
|
||||
tx.execute(
|
||||
"INSERT INTO `app_browser_window_tab_item_page_navigation` (
|
||||
`app_browser_window_tab_item_page_id`
|
||||
|
|
@ -25,7 +25,7 @@ pub fn add(tx: &Transaction, app_browser_window_tab_item_page_id: &i64) -> Resul
|
|||
)
|
||||
}
|
||||
|
||||
pub fn records(
|
||||
pub fn select(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_page_id: &i64,
|
||||
) -> Result<Vec<Table>, Error> {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ impl Request {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_page_navigation_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_item_page_navigation_id) {
|
||||
match database::select(transaction, app_browser_window_tab_item_page_navigation_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match database::delete(transaction, &record.id) {
|
||||
|
|
@ -57,7 +57,7 @@ impl Request {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_page_navigation_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_item_page_navigation_id) {
|
||||
match database::select(transaction, app_browser_window_tab_item_page_navigation_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
// Delegate restore action to the item childs
|
||||
|
|
@ -75,7 +75,7 @@ impl Request {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_page_navigation_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::add(transaction, app_browser_window_tab_item_page_navigation_id) {
|
||||
match database::insert(transaction, app_browser_window_tab_item_page_navigation_id) {
|
||||
Ok(_) => {
|
||||
let id = database::last_insert_id(transaction);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(
|
||||
pub fn insert(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_page_navigation_id: &i64,
|
||||
) -> Result<usize, Error> {
|
||||
|
|
@ -28,7 +28,7 @@ pub fn add(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn records(
|
||||
pub fn select(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_page_navigation_id: &i64,
|
||||
) -> Result<Vec<Table>, Error> {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ impl Widget {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_page_navigation_request_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(
|
||||
match database::select(
|
||||
transaction,
|
||||
app_browser_window_tab_item_page_navigation_request_id,
|
||||
) {
|
||||
|
|
@ -106,7 +106,7 @@ impl Widget {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_page_navigation_request_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(
|
||||
match database::select(
|
||||
transaction,
|
||||
app_browser_window_tab_item_page_navigation_request_id,
|
||||
) {
|
||||
|
|
@ -134,7 +134,7 @@ impl Widget {
|
|||
// Keep value in memory until operation complete
|
||||
let text = self.gobject.text();
|
||||
|
||||
match database::add(
|
||||
match database::insert(
|
||||
transaction,
|
||||
app_browser_window_tab_item_page_navigation_request_id,
|
||||
match text.is_empty() {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(
|
||||
pub fn insert(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_page_navigation_request_id: &i64,
|
||||
text: Option<&str>,
|
||||
|
|
@ -32,7 +32,7 @@ pub fn add(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn records(
|
||||
pub fn select(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_page_navigation_request_id: &i64,
|
||||
) -> Result<Vec<Table>, Error> {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ impl Widget {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_item_id) {
|
||||
match database::select(transaction, app_browser_window_tab_item_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
match database::delete(transaction, &record.id) {
|
||||
|
|
@ -83,7 +83,7 @@ impl Widget {
|
|||
transaction: &Transaction,
|
||||
app_browser_window_tab_item_id: &i64,
|
||||
) -> Result<(), String> {
|
||||
match database::records(transaction, app_browser_window_tab_item_id) {
|
||||
match database::select(transaction, app_browser_window_tab_item_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
// Record value can be stored as NULL
|
||||
|
|
@ -109,7 +109,7 @@ impl Widget {
|
|||
// Keep value in memory until operation complete
|
||||
let title = self.gobject.title();
|
||||
|
||||
match database::add(
|
||||
match database::insert(
|
||||
transaction,
|
||||
app_browser_window_tab_item_id,
|
||||
match title.is_empty() {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub fn init(tx: &Transaction) -> Result<usize, Error> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn add(
|
||||
pub fn insert(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_id: &i64,
|
||||
title: Option<&str>,
|
||||
|
|
@ -32,10 +32,7 @@ pub fn add(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn records(
|
||||
tx: &Transaction,
|
||||
app_browser_window_tab_item_id: &i64,
|
||||
) -> Result<Vec<Table>, Error> {
|
||||
pub fn select(tx: &Transaction, app_browser_window_tab_item_id: &i64) -> Result<Vec<Table>, Error> {
|
||||
let mut stmt = tx.prepare(
|
||||
"SELECT `id`,
|
||||
`app_browser_window_tab_item_id`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue