pub struct Database {
pub base: StarterDatabase,
pub auth: AuthDatabase,
pub logs: LogDatabase,
}
Fields§
§base: StarterDatabase
§auth: AuthDatabase
§logs: LogDatabase
Implementations§
source§impl Database
impl Database
pub async fn new(opts: DatabaseOpts) -> Database
pub async fn init(&self)
sourcepub async fn get_user_by_hashed(
&self,
hashed: String
) -> DefaultReturn<Option<FullUser<String>>>
pub async fn get_user_by_hashed( &self, hashed: String ) -> DefaultReturn<Option<FullUser<String>>>
sourcepub async fn get_user_by_unhashed(
&self,
unhashed: String
) -> DefaultReturn<Option<FullUser<String>>>
pub async fn get_user_by_unhashed( &self, unhashed: String ) -> DefaultReturn<Option<FullUser<String>>>
Get a user by their unhashed ID (hashes ID and then calls Database::get_user_by_hashed()
)
Calls Database::get_user_by_unhashed_st()
if user is invalid.
Arguments:
unhashed
-String
of the user’s unhashed ID
sourcepub async fn get_user_by_unhashed_st(
&self,
unhashed: String
) -> DefaultReturn<Option<FullUser<String>>>
pub async fn get_user_by_unhashed_st( &self, unhashed: String ) -> DefaultReturn<Option<FullUser<String>>>
Get a user by their unhashed secondary token
Arguments:
unhashed
-String
of the user’s unhashed secondary token
sourcepub async fn get_user_by_username(
&self,
username: String
) -> DefaultReturn<Option<FullUser<String>>>
pub async fn get_user_by_username( &self, username: String ) -> DefaultReturn<Option<FullUser<String>>>
sourcepub async fn get_level_by_role(
&self,
name: String
) -> DefaultReturn<RoleLevelLog>
pub async fn get_level_by_role( &self, name: String ) -> DefaultReturn<RoleLevelLog>
sourcepub async fn get_board_by_name(
&self,
url: String
) -> DefaultReturn<Option<Board<String>>>
pub async fn get_board_by_name( &self, url: String ) -> DefaultReturn<Option<Board<String>>>
sourcepub async fn get_boards(
&self,
offset: Option<i32>
) -> DefaultReturn<Option<Vec<BoardIdentifier>>>
pub async fn get_boards( &self, offset: Option<i32> ) -> DefaultReturn<Option<Vec<BoardIdentifier>>>
Get public Board
s by their tags
Arguments:
tags
- space separated list of tags, tags should use “_” instead of a space in their names, all tags should start with “+”offset
- optional value representing the SQL fetch offset
sourcepub async fn get_board_posts(
&self,
url: String,
offset: Option<i32>
) -> DefaultReturn<Option<Vec<Log>>>
pub async fn get_board_posts( &self, url: String, offset: Option<i32> ) -> DefaultReturn<Option<Vec<Log>>>
Get all posts in a Board
by its name
Arguments:
url
- board nameoffset
- optional value representing the SQL fetch offset
sourcepub async fn get_board_posts_by_tag(
&self,
url: String,
tags: String,
offset: Option<i32>
) -> DefaultReturn<Option<Vec<Log>>>
pub async fn get_board_posts_by_tag( &self, url: String, tags: String, offset: Option<i32> ) -> DefaultReturn<Option<Vec<Log>>>
Get all posts in a Board
by its name and their tags
Arguments:
url
- board nametags
- space separated list of tags, tags should use “_” instead of a space in their names, all tags should start with “+”offset
- optional value representing the SQL fetch offset
sourcepub async fn get_pinned_board_posts(
&self,
url: String
) -> DefaultReturn<Option<Vec<Log>>>
pub async fn get_pinned_board_posts( &self, url: String ) -> DefaultReturn<Option<Vec<Log>>>
sourcepub async fn get_post_replies_limited(
&self,
id: String,
run_existing_check: bool,
offset: Option<i32>
) -> DefaultReturn<Option<Vec<Log>>>
pub async fn get_post_replies_limited( &self, id: String, run_existing_check: bool, offset: Option<i32> ) -> DefaultReturn<Option<Vec<Log>>>
Get all posts in a Board
by its name that are replying to another BoardPostLog
(limited form)
Arguments:
id
- post idrun_existing_check
- if we should check that the log exists first
sourcepub async fn get_post_replies(
&self,
id: String,
run_existing_check: bool
) -> DefaultReturn<Option<Vec<LogIdentifier>>>
pub async fn get_post_replies( &self, id: String, run_existing_check: bool ) -> DefaultReturn<Option<Vec<LogIdentifier>>>
Get all posts in a Board
by its name that are replying to another BoardPostLog
- only includes post id
Arguments:
id
- post idrun_existing_check
- if we should check that the log exists first
sourcepub async fn get_boards_by_owner(
&self,
owner: String
) -> DefaultReturn<Option<Vec<BoardIdentifier>>>
pub async fn get_boards_by_owner( &self, owner: String ) -> DefaultReturn<Option<Vec<BoardIdentifier>>>
sourcepub async fn fetch_most_recent_posts(
&self,
offset: Option<i32>
) -> DefaultReturn<Option<Vec<Log>>>
pub async fn fetch_most_recent_posts( &self, offset: Option<i32> ) -> DefaultReturn<Option<Vec<Log>>>
Get most recent posts from all Boards
Arguments:
offset
- optional value representing the SQL fetch offset
sourcepub async fn get_user_posts_count(&self, user: String) -> DefaultReturn<usize>
pub async fn get_user_posts_count(&self, user: String) -> DefaultReturn<usize>
Get the amount of posts a user has created in all boards
Arguments:
user
- username of user to check
sourcepub async fn create_board(
&self,
props: &mut Board<String>,
as_user: Option<String>
) -> DefaultReturn<Option<Board<String>>>
pub async fn create_board( &self, props: &mut Board<String>, as_user: Option<String> ) -> DefaultReturn<Option<Board<String>>>
Create a new Board
given various properties
Arguments:
props
-Board<String>
as_user
- The ID of the user creating the board
sourcepub async fn create_board_post(
&self,
props: &mut BoardPostLog,
as_user: Option<String>,
as_role: Option<RoleLevel>
) -> DefaultReturn<Option<String>>
pub async fn create_board_post( &self, props: &mut BoardPostLog, as_user: Option<String>, as_role: Option<RoleLevel> ) -> DefaultReturn<Option<String>>
Create a new post in a given Board
Arguments:
props
-BoardPostLog
as_user
- The ID of the user creating the post
sourcepub async fn edit_board_metadata_by_name(
&self,
name: String,
metadata: BoardMetadata,
edit_as: Option<String>
) -> DefaultReturn<Option<String>>
pub async fn edit_board_metadata_by_name( &self, name: String, metadata: BoardMetadata, edit_as: Option<String> ) -> DefaultReturn<Option<String>>
Update a Board
’s metadata by its custom_url
sourcepub async fn delete_board(&self, name: String) -> DefaultReturn<Option<String>>
pub async fn delete_board(&self, name: String) -> DefaultReturn<Option<String>>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more