Struct bundlrs::db::Database

source ·
pub struct Database {
    pub base: StarterDatabase,
    pub auth: AuthDatabase,
    pub logs: LogDatabase,
}

Fields§

§base: StarterDatabase§auth: AuthDatabase§logs: LogDatabase

Implementations§

source§

impl Database

source

pub async fn new(opts: DatabaseOpts) -> Database

source

pub async fn init(&self)

source

pub async fn get_user_by_unhashed( &self, unhashed: String ) -> DefaultReturn<Option<FullUser<String>>>

Get a user by their unhashed ID

Arguments:
  • unhashed - String of the user’s unhashed ID
source

pub async fn get_user_by_username( &self, username: String ) -> DefaultReturn<Option<FullUser<String>>>

Get a user by their username

Arguments:
  • username - String of the user’s username
source

pub async fn ban_user_by_name( &self, name: String ) -> DefaultReturn<Option<String>>

Ban a UserState by its username

source

async fn count_paste_views(&self, custom_url: String) -> usize

Count the view_paste logs for a specific Paste

source

async fn build_result_from_query( &self, query: &str, selector: &str ) -> DefaultReturn<Option<FullPaste<PasteMetadata, String>>>

Build a Paste query with information about it

source

pub async fn get_paste_by_url( &self, url: String ) -> DefaultReturn<Option<FullPaste<PasteMetadata, String>>>

Get a Paste given its custom_url

Arguments:
  • url - String of the paste’s custom_url
source

pub async fn get_paste_by_id( &self, id: String ) -> DefaultReturn<Option<FullPaste<PasteMetadata, String>>>

Get a Paste given its id

Arguments:
  • id - String of the paste’s id
source

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’s username
  • offset - optional value representing the SQL fetch offset
source

pub async fn get_all_pastes_limited( &self, offset: Option<i32> ) -> DefaultReturn<Option<Vec<PasteIdentifier>>>

Get all pastes (limited)

Arguments:
  • offset - optional value representing the SQL fetch offset
source

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 by
  • offset - optional value representing the SQL fetch offset
source

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
source

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

source

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

source

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
source

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

source

pub async fn get_group_by_name( &self, url: String ) -> DefaultReturn<Option<Group<String>>>

Get a Group by its name

Arguments:
  • url - group name
source

pub async fn create_group( &self, props: Group<GroupMetadata> ) -> DefaultReturn<Option<String>>

Create a new Group by its name

Arguments:
source

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§

source§

impl Clone for Database

source§

fn clone(&self) -> Database

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more