1
use crate::{
2
    schema::{Schema, SchemaName, Schematic},
3
    Error,
4
};
5

            
6
#[doc(hidden)]
7
pub mod database;
8
#[cfg(feature = "multiuser")]
9
#[doc(hidden)]
10
pub mod group;
11
#[doc(hidden)]
12
#[cfg(feature = "multiuser")]
13
pub mod role;
14
#[cfg(feature = "multiuser")]
15
#[doc(hidden)]
16
pub mod user;
17

            
18
pub use self::database::Database;
19
#[cfg(feature = "multiuser")]
20
pub use self::{group::PermissionGroup, role::Role, user::User};
21

            
22
/// The `BonsaiDb` administration schema.
23
#[derive(Debug)]
24
pub struct Admin;
25

            
26
impl Schema for Admin {
27
46483
    fn schema_name() -> SchemaName {
28
46483
        SchemaName::new("khonsulabs", "bonsaidb-admin")
29
46483
    }
30

            
31
    fn define_collections(schema: &mut Schematic) -> Result<(), Error> {
32
40503
        schema.define_collection::<database::Database>()?;
33

            
34
        #[cfg(feature = "multiuser")]
35
        {
36
40503
            schema.define_collection::<group::PermissionGroup>()?;
37
40503
            schema.define_collection::<role::Role>()?;
38
40503
            schema.define_collection::<user::User>()?;
39
        }
40

            
41
40503
        Ok(())
42
40503
    }
43
}
44

            
45
/// The name of the admin database.
46
pub const ADMIN_DATABASE_NAME: &str = "_admin";