1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use revolt_result::Result;

use crate::{Bot, FieldsBot, PartialBot};

mod mongodb;
mod reference;

#[async_trait]
pub trait AbstractBots: Sync + Send {
    /// Insert new bot into the database
    async fn insert_bot(&self, bot: &Bot) -> Result<()>;

    /// Fetch a bot by its id
    async fn fetch_bot(&self, id: &str) -> Result<Bot>;

    /// Fetch a bot by its token
    async fn fetch_bot_by_token(&self, token: &str) -> Result<Bot>;

    /// Fetch bots owned by a user
    async fn fetch_bots_by_user(&self, user_id: &str) -> Result<Vec<Bot>>;

    /// Get the number of bots owned by a user
    async fn get_number_of_bots_by_user(&self, user_id: &str) -> Result<usize>;

    /// Update bot with new information
    async fn update_bot(
        &self,
        id: &str,
        partial: &PartialBot,
        remove: Vec<FieldsBot>,
    ) -> Result<()>;

    /// Delete a bot from the database
    async fn delete_bot(&self, id: &str) -> Result<()>;
}