use shared pointer for profile_id value

This commit is contained in:
yggverse 2024-11-14 13:32:53 +02:00
parent fa7080762e
commit be30ec660f
3 changed files with 7 additions and 7 deletions

View file

@ -11,14 +11,14 @@ pub struct Table {
pub struct Database {
connection: Rc<RwLock<Connection>>,
profile_id: i64, // multi-profile relationship @TODO shared reference?
profile_id: Rc<i64>, // multi-profile relationship
}
impl Database {
// Constructors
/// Create new `Self`
pub fn new(connection: Rc<RwLock<Connection>>, profile_id: i64) -> Self {
pub fn new(connection: Rc<RwLock<Connection>>, profile_id: Rc<i64>) -> Self {
Self {
connection,
profile_id,
@ -31,7 +31,7 @@ impl Database {
pub fn records(&self, request: Option<&str>) -> Vec<Table> {
let readable = self.connection.read().unwrap();
let tx = readable.unchecked_transaction().unwrap();
select(&tx, self.profile_id, request).unwrap()
select(&tx, *self.profile_id, request).unwrap()
}
// Setters
@ -44,7 +44,7 @@ impl Database {
let tx = writable.transaction().unwrap();
// Create new record
insert(&tx, self.profile_id, time, request).unwrap();
insert(&tx, *self.profile_id, time, request).unwrap();
// Hold insert ID for result
let id = last_insert_id(&tx);