25 lines
658 B
Rust
25 lines
658 B
Rust
/// Helper module for database persistence operations
|
|
use diesel::prelude::*;
|
|
use diesel::sqlite::SqliteConnection;
|
|
|
|
/// Establish a database connection
|
|
pub fn establish_connection(database_url: &str) -> Result<SqliteConnection, diesel::ConnectionError> {
|
|
SqliteConnection::establish(database_url)
|
|
}
|
|
|
|
/// Generic record for simple id/name/data pattern
|
|
#[derive(Queryable)]
|
|
pub struct SimpleRecord {
|
|
pub id: Option<i32>,
|
|
pub name: String,
|
|
pub data: String,
|
|
}
|
|
|
|
/// Generic record for text-based primary keys
|
|
#[derive(Queryable)]
|
|
pub struct TextKeyRecord {
|
|
pub key: Option<String>,
|
|
pub secondary: Option<String>,
|
|
pub data: String,
|
|
}
|