Struct vibrant::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 fn sort_hashmap_by_keys<T>( &self, hashmap: HashMap<String, T> ) -> Vec<(String, T)>

Sort a hashmap by its keys from shortest to longest

source

pub async fn general_query( &self, query: String ) -> DefaultReturn<Vec<HashMap<String, String>>>

Run a general SQL query and return the result

source

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

Get a Project by its name.

§Arguments:
  • name - project name
source

pub async fn get_projects_by_owner_limited( &self, owner: String, offset: Option<i32> ) -> DefaultReturn<Option<Vec<PCreateProject>>>

Get all projects owned by a specific user (limited), sorted by billing period start

§Arguments:
  • owner - String of the owner’s username
  • offset - optional value representing the SQL fetch offset
source

pub async fn create_project( &self, props: &mut PCreateProject, as_user: Option<String> ) -> DefaultReturn<Option<PCreateProject>>

Create a new Project given various properties

§Arguments:
source

pub async fn edit_fields_by_name( &self, name: String, fields: PEditFieldsByName, edit_as: Option<String>, bypass_user_checks: bool ) -> DefaultReturn<Option<String>>

Update a Project’s fields by its name

source

pub async fn incr_project_requests(&self, name: String) -> bool

Increment a Project’s billing request limit (redis)

§Arguments:
  • name - project name
source

pub async fn edit_project_metadata_by_name( &self, name: String, metadata: ProjectMetadata, edit_as: Option<String> ) -> DefaultReturn<Option<String>>

Update a Project’s metadata by its name

source

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

Update a Project’s private metadata by its name

source

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

Delete a Project given its name

source

pub async fn get_file_in_project( &self, name: String, path: String, as_user: Option<String>, bypass_user_checks: bool, protected: bool ) -> DefaultReturn<Option<Vec<u8>>>

Get a file by path in the given Project

source

pub async fn get_project_files( &self, name: String, as_user: Option<String>, bypass_user_checks: bool ) -> DefaultReturn<Vec<String>>

Get all file (names) in the given Project

source

pub async fn store_file_in_project( &self, name: String, path: String, content: String, edit_as: Option<String> ) -> DefaultReturn<Option<String>>

Create a file by path in the given Project

source

pub async fn update_file_in_project( &self, name: String, path: String, content: String, edit_as: Option<String> ) -> DefaultReturn<Option<String>>

Update a file by path in the given Project

source

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

Delete a file by path in the given Project

source

pub async fn move_file_in_project( &self, name: String, path: String, new_path: String, edit_as: Option<String> ) -> DefaultReturn<Option<String>>

Move a file by path to new_path in the given Project

source

pub async fn get_project_favorites(&self, name: String) -> DefaultReturn<i32>

Get the number of ProjectFavoriteLogs a Project has

source

pub async fn get_user_project_favorite( &self, user: String, project: String, skip_existing_check: bool ) -> DefaultReturn<Option<Log>>

source

pub async fn toggle_user_project_favorite( &self, user: String, project: String ) -> DefaultReturn<Option<String>>

Toggle a ProjectFavoriteLog on a Project by user and project

source

pub async fn get_project_score( &self, project: String ) -> DefaultReturn<Option<Score>>

Get a Project score from the /.secrets/palette.toml file

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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

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 T
where 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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 T
where 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