summaryrefslogtreecommitdiff
path: root/backend/core/src/queries/accounts/get_all.rs
blob: ab53729d48cdfc4bf12726f0a87a7fa11593094c (plain)
1
2
3
4
5
6
7
8
9
10
use anyhow::{Context, Result};
use crate::{models::account::Account, schema::accounts::dsl::accounts};
use diesel::{QueryDsl, RunQueryDsl, SelectableHelper, SqliteConnection};

pub fn get_all_accounts(connection: &mut SqliteConnection) -> Result<Vec<Account>> {
    let all_accounts = accounts.select(Account::as_select())
        .load(connection)
        .with_context(|| "failed to get all accounts")?;
    Ok(all_accounts)
}