revolt_database/models/bots/
ops.rs

1use revolt_result::Result;
2
3use crate::{Bot, FieldsBot, PartialBot};
4
5#[cfg(feature = "mongodb")]
6mod mongodb;
7mod reference;
8
9#[async_trait]
10pub trait AbstractBots: Sync + Send {
11    /// Insert new bot into the database
12    async fn insert_bot(&self, bot: &Bot) -> Result<()>;
13
14    /// Fetch a bot by its id
15    async fn fetch_bot(&self, id: &str) -> Result<Bot>;
16
17    /// Fetch a bot by its token
18    async fn fetch_bot_by_token(&self, token: &str) -> Result<Bot>;
19
20    /// Fetch bots owned by a user
21    async fn fetch_bots_by_user(&self, user_id: &str) -> Result<Vec<Bot>>;
22
23    /// Get the number of bots owned by a user
24    async fn get_number_of_bots_by_user(&self, user_id: &str) -> Result<usize>;
25
26    /// Update bot with new information
27    async fn update_bot(
28        &self,
29        id: &str,
30        partial: &PartialBot,
31        remove: Vec<FieldsBot>,
32    ) -> Result<()>;
33
34    /// Delete a bot from the database
35    async fn delete_bot(&self, id: &str) -> Result<()>;
36}