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_unhashed(
&self,
unhashed: String
) -> DefaultReturn<Option<FullUser<String>>>
pub async fn get_user_by_unhashed( &self, unhashed: String ) -> DefaultReturn<Option<FullUser<String>>>
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 ban_user_by_name(
&self,
name: String
) -> DefaultReturn<Option<String>>
pub async fn ban_user_by_name( &self, name: String ) -> DefaultReturn<Option<String>>
Ban a UserState
by its username
sourceasync fn count_paste_views(&self, custom_url: String) -> usize
async fn count_paste_views(&self, custom_url: String) -> usize
Count the view_paste
logs for a specific Paste
sourceasync fn build_result_from_query(
&self,
query: &str,
selector: &str
) -> DefaultReturn<Option<FullPaste<PasteMetadata, String>>>
async fn build_result_from_query( &self, query: &str, selector: &str ) -> DefaultReturn<Option<FullPaste<PasteMetadata, String>>>
Build a Paste
query with information about it
sourcepub async fn get_paste_by_url(
&self,
url: String
) -> DefaultReturn<Option<FullPaste<PasteMetadata, String>>>
pub async fn get_paste_by_url( &self, url: String ) -> DefaultReturn<Option<FullPaste<PasteMetadata, String>>>
sourcepub async fn get_paste_by_id(
&self,
id: String
) -> DefaultReturn<Option<FullPaste<PasteMetadata, String>>>
pub async fn get_paste_by_id( &self, id: String ) -> DefaultReturn<Option<FullPaste<PasteMetadata, String>>>
sourcepub async fn get_pastes_by_owner_limited(
&self,
owner: String,
offset: Option<i32>
) -> DefaultReturn<Option<Vec<PasteIdentifier>>>
pub async fn get_pastes_by_owner_limited( &self, owner: String, offset: Option<i32> ) -> DefaultReturn<Option<Vec<PasteIdentifier>>>
Get all pastes owned by a specific user (limited)
Arguments:
owner
-String
of the owner’susername
offset
- optional value representing the SQL fetch offset
sourcepub async fn get_all_pastes_limited(
&self,
offset: Option<i32>
) -> DefaultReturn<Option<Vec<PasteIdentifier>>>
pub async fn get_all_pastes_limited( &self, offset: Option<i32> ) -> DefaultReturn<Option<Vec<PasteIdentifier>>>
sourcepub async fn get_all_pastes_by_content_limited(
&self,
content: String,
offset: Option<i32>
) -> DefaultReturn<Option<Vec<PasteIdentifier>>>
pub async fn get_all_pastes_by_content_limited( &self, content: String, offset: Option<i32> ) -> DefaultReturn<Option<Vec<PasteIdentifier>>>
Get all pastes (limited)
Arguments:
content
- value representing the content to search byoffset
- optional value representing the SQL fetch offset
sourcepub async fn create_paste(
&self,
props: &mut Paste<String>,
as_user: Option<String>
) -> DefaultReturn<Option<Paste<String>>>
pub async fn create_paste( &self, props: &mut Paste<String>, as_user: Option<String> ) -> DefaultReturn<Option<Paste<String>>>
Create a new Paste
given various properties
Arguments:
props
-Paste<String>
as_user
- The ID of the user creating the paste
sourcepub async fn edit_paste_by_url(
&self,
url: String,
content: String,
edit_password: String,
new_url: Option<String>,
new_edit_password: Option<String>,
edit_as: Option<String>
) -> DefaultReturn<Option<String>>
pub async fn edit_paste_by_url( &self, url: String, content: String, edit_password: String, new_url: Option<String>, new_edit_password: Option<String>, edit_as: Option<String> ) -> DefaultReturn<Option<String>>
Edit an existing Paste
given its custom_url
sourcepub async fn edit_paste_metadata_by_url(
&self,
url: String,
metadata: PasteMetadata,
edit_password: String,
edit_as: Option<String>,
skip_edit_check: bool
) -> DefaultReturn<Option<String>>
pub async fn edit_paste_metadata_by_url( &self, url: String, metadata: PasteMetadata, edit_password: String, edit_as: Option<String>, skip_edit_check: bool ) -> DefaultReturn<Option<String>>
Update a Paste
’s metadata by its custom_url
sourcepub async fn add_view_to_url(
&self,
url: &String,
view_as: &String
) -> DefaultReturn<Option<String>>
pub async fn add_view_to_url( &self, url: &String, view_as: &String ) -> DefaultReturn<Option<String>>
Count a view to a Paste
given its custom_url
Arguments:
view_as
- The username of the account that viewed the paste
sourcepub async fn delete_paste_by_url(
&self,
url: String,
edit_password: String,
delete_as: Option<String>
) -> DefaultReturn<Option<String>>
pub async fn delete_paste_by_url( &self, url: String, edit_password: String, delete_as: Option<String> ) -> DefaultReturn<Option<String>>
Delete a Paste
given its custom_url
and edit_password
sourcepub async fn get_group_by_name(
&self,
url: String
) -> DefaultReturn<Option<Group<String>>>
pub async fn get_group_by_name( &self, url: String ) -> DefaultReturn<Option<Group<String>>>
sourcepub async fn create_group(
&self,
props: Group<GroupMetadata>
) -> DefaultReturn<Option<String>>
pub async fn create_group( &self, props: Group<GroupMetadata> ) -> DefaultReturn<Option<String>>
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
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