mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
change argument data type
This commit is contained in:
parent
a95832f5fc
commit
f81e496fa4
@ -43,7 +43,7 @@ impl Database {
|
|||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
/// Create new record in `Self` database connected
|
/// Create new record in `Self` database connected
|
||||||
pub fn add(&self, is_active: bool, time: DateTime, name: Option<&str>) -> Result<i64, ()> {
|
pub fn add(&self, is_active: bool, time: DateTime, name: Option<String>) -> Result<i64, ()> {
|
||||||
// Begin new transaction
|
// Begin new transaction
|
||||||
let mut writable = self.connection.write().unwrap();
|
let mut writable = self.connection.write().unwrap();
|
||||||
let tx = writable.transaction().unwrap();
|
let tx = writable.transaction().unwrap();
|
||||||
@ -52,13 +52,7 @@ impl Database {
|
|||||||
if is_active {
|
if is_active {
|
||||||
// Deactivate other records as only one profile should be active
|
// Deactivate other records as only one profile should be active
|
||||||
for record in select(&tx).unwrap() {
|
for record in select(&tx).unwrap() {
|
||||||
let _ = update(
|
let _ = update(&tx, record.id, false, record.time, record.name);
|
||||||
&tx,
|
|
||||||
record.id,
|
|
||||||
false,
|
|
||||||
record.time,
|
|
||||||
record.name.as_ref().map(|x| x.as_str()),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +83,7 @@ impl Database {
|
|||||||
record.id,
|
record.id,
|
||||||
if record.id == id { true } else { false },
|
if record.id == id { true } else { false },
|
||||||
record.time,
|
record.time,
|
||||||
record.name.as_ref().map(|x| x.as_str()),
|
record.name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +114,7 @@ pub fn insert(
|
|||||||
tx: &Transaction,
|
tx: &Transaction,
|
||||||
is_active: bool,
|
is_active: bool,
|
||||||
time: DateTime,
|
time: DateTime,
|
||||||
name: Option<&str>,
|
name: Option<String>,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
tx.execute(
|
tx.execute(
|
||||||
"INSERT INTO `profile` (
|
"INSERT INTO `profile` (
|
||||||
@ -137,7 +131,7 @@ pub fn update(
|
|||||||
id: i64,
|
id: i64,
|
||||||
is_active: bool,
|
is_active: bool,
|
||||||
time: DateTime,
|
time: DateTime,
|
||||||
name: Option<&str>,
|
name: Option<String>,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
tx.execute(
|
tx.execute(
|
||||||
"UPDATE `profile` SET `is_active` = ?, `time` = ?, `name` = ? WHERE `id` = ?",
|
"UPDATE `profile` SET `is_active` = ?, `time` = ?, `name` = ? WHERE `id` = ?",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user