diff options
| author | Joe Carstairs <me@joeac.net> | 2024-10-22 07:46:43 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2024-10-22 07:46:43 +0100 |
| commit | 5824c353f978a5b9ab9696451ee3014c6a614ffc (patch) | |
| tree | bc39754ca417e84eb00b0aa9a1ae2330da0bf282 /backend/core/src/queries/accounts/get_all.rs | |
| parent | 7adaace61a4fe983eba5ded3aaaf624ce6fb9014 (diff) | |
Refactors importer to use core stuff
Diffstat (limited to 'backend/core/src/queries/accounts/get_all.rs')
| -rw-r--r-- | backend/core/src/queries/accounts/get_all.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/backend/core/src/queries/accounts/get_all.rs b/backend/core/src/queries/accounts/get_all.rs new file mode 100644 index 0000000..ab53729 --- /dev/null +++ b/backend/core/src/queries/accounts/get_all.rs @@ -0,0 +1,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) +} |
