pub struct View {
pub name: String,
pub schema: Option<String>,
pub columns: Vec<Column>,
pub ddl: Option<String>,
pub materialized: bool,
pub refresh_strategy: Option<RefreshStrategy>,
pub dependencies: Vec<String>,
pub indexes: Vec<Index>,
}Expand description
Represents a database view
Fields§
§name: String§schema: Option<String>§columns: Vec<Column>§ddl: Option<String>§materialized: bool§refresh_strategy: Option<RefreshStrategy>§dependencies: Vec<String>§indexes: Vec<Index>Implementations§
Source§impl View
impl View
Sourcepub fn with_schema(self, schema: impl Into<String>) -> Self
pub fn with_schema(self, schema: impl Into<String>) -> Self
Create a new view with schema
Sourcepub fn add_column(self, column: Column) -> Self
pub fn add_column(self, column: Column) -> Self
Add a column to the view
Sourcepub fn set_schema(&mut self, schema: impl Into<String>) -> &mut Self
pub fn set_schema(&mut self, schema: impl Into<String>) -> &mut Self
Set the schema (in-place)
Sourcepub fn add_column_mut(&mut self, column: Column) -> &mut Self
pub fn add_column_mut(&mut self, column: Column) -> &mut Self
Add a column (in-place)
Sourcepub fn set_materialized(&mut self, materialized: bool) -> &mut Self
pub fn set_materialized(&mut self, materialized: bool) -> &mut Self
Set the view as materialized
Sourcepub fn set_refresh_strategy(&mut self, strategy: RefreshStrategy) -> &mut Self
pub fn set_refresh_strategy(&mut self, strategy: RefreshStrategy) -> &mut Self
Set the refresh strategy for materialized views
Sourcepub fn add_dependency(&mut self, dependency: impl Into<String>) -> &mut Self
pub fn add_dependency(&mut self, dependency: impl Into<String>) -> &mut Self
Add a dependency (table or view that this view depends on)
Sourcepub fn set_dependencies(&mut self, dependencies: Vec<String>) -> &mut Self
pub fn set_dependencies(&mut self, dependencies: Vec<String>) -> &mut Self
Set multiple dependencies at once
Sourcepub fn add_index(
&mut self,
name: impl Into<String>,
columns: Vec<String>,
) -> &mut Self
pub fn add_index( &mut self, name: impl Into<String>, columns: Vec<String>, ) -> &mut Self
Add an index to the view (useful for materialized views)
Sourcepub fn add_unique_index(
&mut self,
name: impl Into<String>,
columns: Vec<String>,
) -> &mut Self
pub fn add_unique_index( &mut self, name: impl Into<String>, columns: Vec<String>, ) -> &mut Self
Add a unique index to the view
Sourcepub fn generate_ddl(&self) -> String
pub fn generate_ddl(&self) -> String
Generate the DDL for creating this view
Sourcepub fn generate_refresh_ddl(&self) -> Option<String>
pub fn generate_refresh_ddl(&self) -> Option<String>
Generate the DDL for refreshing a materialized view
Sourcepub fn generate_all_ddl(&self) -> Vec<String>
pub fn generate_all_ddl(&self) -> Vec<String>
Get all DDL statements for this view (CREATE + indexes + refresh if materialized)
Trait Implementations§
Source§impl IgnisObject for View
impl IgnisObject for View
impl StructuralPartialEq for View
Auto Trait Implementations§
impl Freeze for View
impl RefUnwindSafe for View
impl Send for View
impl Sync for View
impl Unpin for View
impl UnsafeUnpin for View
impl UnwindSafe for View
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 more