add: move database drivers to oiseau
This commit is contained in:
parent
40fce4bc77
commit
81036e3733
57 changed files with 638 additions and 1106 deletions
|
@ -1,5 +1,4 @@
|
|||
use super::*;
|
||||
use crate::cache::Cache;
|
||||
use oiseau::cache::Cache;
|
||||
use crate::model::communities::{Community, Poll, Post, Question};
|
||||
use crate::model::stacks::{StackMode, StackSort};
|
||||
use crate::model::{
|
||||
|
@ -8,19 +7,21 @@ use crate::model::{
|
|||
permissions::FinePermission,
|
||||
stacks::{StackPrivacy, UserStack},
|
||||
};
|
||||
use crate::{auto_method, execute, get, query_row, query_rows, params};
|
||||
use crate::{auto_method, DataManager};
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
use rusqlite::Row;
|
||||
use oiseau::SqliteRow;
|
||||
|
||||
#[cfg(feature = "postgres")]
|
||||
use tokio_postgres::Row;
|
||||
use oiseau::PostgresRow;
|
||||
|
||||
use oiseau::{execute, get, query_rows, params};
|
||||
|
||||
impl DataManager {
|
||||
/// Get a [`UserStack`] from an SQL row.
|
||||
pub(crate) fn get_stack_from_row(
|
||||
#[cfg(feature = "sqlite")] x: &Row<'_>,
|
||||
#[cfg(feature = "postgres")] x: &Row,
|
||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
||||
) -> UserStack {
|
||||
UserStack {
|
||||
id: get!(x->0(i64)) as usize,
|
||||
|
@ -99,7 +100,7 @@ impl DataManager {
|
|||
/// # Arguments
|
||||
/// * `id` - the ID of the user to fetch stacks for
|
||||
pub async fn get_stacks_by_owner(&self, id: usize) -> Result<Vec<UserStack>> {
|
||||
let conn = match self.connect().await {
|
||||
let conn = match self.0.connect().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||
};
|
||||
|
@ -146,7 +147,7 @@ impl DataManager {
|
|||
}
|
||||
|
||||
// ...
|
||||
let conn = match self.connect().await {
|
||||
let conn = match self.0.connect().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||
};
|
||||
|
@ -182,7 +183,7 @@ impl DataManager {
|
|||
}
|
||||
|
||||
// ...
|
||||
let conn = match self.connect().await {
|
||||
let conn = match self.0.connect().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||
};
|
||||
|
@ -193,7 +194,7 @@ impl DataManager {
|
|||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
self.2.remove(format!("atto.stack:{}", id)).await;
|
||||
self.0.1.remove(format!("atto.stack:{}", id)).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue