Skip to main content

revolt_database/models/accounts/
ops.rs

1use revolt_result::Result;
2
3use crate::Account;
4
5#[cfg(feature = "mongodb")]
6mod mongodb;
7mod reference;
8
9#[async_trait]
10pub trait AbstractAccounts: Sync + Send {
11    /// Find account by id
12    async fn fetch_account(&self, id: &str) -> Result<Account>;
13
14    /// Find account by normalised email
15    async fn fetch_account_by_normalised_email(
16        &self,
17        normalised_email: &str,
18    ) -> Result<Option<Account>>;
19
20    /// Find account with active pending email verification
21    async fn fetch_account_with_email_verification(&self, token: &str) -> Result<Account>;
22
23    /// Find account with active password reset
24    async fn fetch_account_with_password_reset(&self, token: &str) -> Result<Account>;
25
26    /// Find account with active deletion token
27    async fn fetch_account_with_deletion_token(&self, token: &str) -> Result<Account>;
28
29    /// Find accounts which are due to be deleted
30    async fn fetch_accounts_due_for_deletion(&self) -> Result<Vec<Account>>;
31
32    // Save account
33    async fn save_account(&self, account: &Account) -> Result<()>;
34}