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 fn sort_hashmap_by_keys<T>(
&self,
hashmap: HashMap<String, T>
) -> Vec<(String, T)>
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
sourcepub async fn general_query(
&self,
query: String
) -> DefaultReturn<Vec<HashMap<String, String>>>
pub async fn general_query( &self, query: String ) -> DefaultReturn<Vec<HashMap<String, String>>>
Run a general SQL query and return the result
sourcepub async fn get_project_by_id(
&self,
name: String
) -> DefaultReturn<Option<Project>>
pub async fn get_project_by_id( &self, name: String ) -> DefaultReturn<Option<Project>>
sourcepub async fn get_projects_by_owner_limited(
&self,
owner: String,
offset: Option<i32>
) -> DefaultReturn<Option<Vec<PCreateProject>>>
pub async fn get_projects_by_owner_limited( &self, owner: String, offset: Option<i32> ) -> DefaultReturn<Option<Vec<PCreateProject>>>
sourcepub async fn create_project(
&self,
props: &mut PCreateProject,
as_user: Option<String>
) -> DefaultReturn<Option<PCreateProject>>
pub async fn create_project( &self, props: &mut PCreateProject, as_user: Option<String> ) -> DefaultReturn<Option<PCreateProject>>
Create a new Project
given various properties
§Arguments:
props
-(PROPS)CreateProject
as_user
- The username of the user creating the project
sourcepub async fn edit_fields_by_name(
&self,
name: String,
fields: PEditFieldsByName,
edit_as: Option<String>,
bypass_user_checks: bool
) -> DefaultReturn<Option<String>>
pub async fn edit_fields_by_name( &self, name: String, fields: PEditFieldsByName, edit_as: Option<String>, bypass_user_checks: bool ) -> DefaultReturn<Option<String>>
sourcepub async fn incr_project_requests(&self, name: String) -> bool
pub async fn incr_project_requests(&self, name: String) -> bool
sourcepub async fn edit_project_metadata_by_name(
&self,
name: String,
metadata: ProjectMetadata,
edit_as: Option<String>
) -> DefaultReturn<Option<String>>
pub async fn edit_project_metadata_by_name( &self, name: String, metadata: ProjectMetadata, edit_as: Option<String> ) -> DefaultReturn<Option<String>>
sourcepub async fn edit_project_private_metadata_by_name(
&self,
name: String,
metadata: ProjectPrivateMetadata
) -> DefaultReturn<Option<String>>
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
sourcepub async fn delete_project(
&self,
name: String,
delete_as: Option<String>
) -> DefaultReturn<Option<String>>
pub async fn delete_project( &self, name: String, delete_as: Option<String> ) -> DefaultReturn<Option<String>>
Delete a Project
given its name
sourcepub 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>>>
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
sourcepub async fn get_project_files(
&self,
name: String,
as_user: Option<String>,
bypass_user_checks: bool
) -> DefaultReturn<Vec<String>>
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
sourcepub async fn store_file_in_project(
&self,
name: String,
path: String,
content: String,
edit_as: Option<String>
) -> DefaultReturn<Option<String>>
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
sourcepub async fn update_file_in_project(
&self,
name: String,
path: String,
content: String,
edit_as: Option<String>
) -> DefaultReturn<Option<String>>
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
sourcepub async fn delete_file_in_project(
&self,
name: String,
path: String,
edit_as: Option<String>
) -> DefaultReturn<Option<String>>
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
sourcepub async fn move_file_in_project(
&self,
name: String,
path: String,
new_path: String,
edit_as: Option<String>
) -> DefaultReturn<Option<String>>
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
sourcepub async fn get_project_favorites(&self, name: String) -> DefaultReturn<i32>
pub async fn get_project_favorites(&self, name: String) -> DefaultReturn<i32>
Get the number of ProjectFavoriteLog
s a Project
has
pub async fn get_user_project_favorite( &self, user: String, project: String, skip_existing_check: bool ) -> DefaultReturn<Option<Log>>
sourcepub async fn toggle_user_project_favorite(
&self,
user: String,
project: String
) -> DefaultReturn<Option<String>>
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
sourcepub async fn get_project_score(
&self,
project: String
) -> DefaultReturn<Option<Score>>
pub async fn get_project_score( &self, project: String ) -> DefaultReturn<Option<Score>>
Get a Project
score from the /.secrets/palette.toml
file
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request