pub struct Table {
pub name: String,
pub schema: Option<String>,
pub columns: Vec<Column>,
pub primary_key: Option<String>,
pub constraints: Vec<Constraint>,
pub indexes: Vec<Index>,
pub rls_enabled: bool,
pub policies: Vec<Policy>,
}Expand description
Represents a database table
Fields§
§name: String§schema: Option<String>§columns: Vec<Column>§primary_key: Option<String>§constraints: Vec<Constraint>§indexes: Vec<Index>§rls_enabled: bool§policies: Vec<Policy>Implementations§
Source§impl Table
impl Table
Sourcepub fn with_schema(schema: impl Into<String>, name: impl Into<String>) -> Self
pub fn with_schema(schema: impl Into<String>, name: impl Into<String>) -> Self
Create a new table with schema
Sourcepub fn add_column(self, column: Column) -> Self
pub fn add_column(self, column: Column) -> Self
Add a column to the table
Sourcepub fn set_primary_key(self, pk_column: impl Into<String>) -> Self
pub fn set_primary_key(self, pk_column: impl Into<String>) -> Self
Set the primary key column
Sourcepub fn add_constraint(self, constraint: Constraint) -> Self
pub fn add_constraint(self, constraint: Constraint) -> Self
Add a constraint to the table
Sourcepub fn column(&mut self, name: &str) -> Option<&mut Column>
pub fn column(&mut self, name: &str) -> Option<&mut Column>
Get a mutable reference to a column for configuration
Sourcepub fn generate_ddl(&self) -> String
pub fn generate_ddl(&self) -> String
Generate the DDL for creating this table
Sourcepub fn enable_rls(self) -> Self
pub fn enable_rls(self) -> Self
Enable Row-Level Security on this table
Sourcepub fn disable_rls(self) -> Self
pub fn disable_rls(self) -> Self
Disable Row-Level Security on this table
Sourcepub fn add_policy(self, policy: Policy) -> Self
pub fn add_policy(self, policy: Policy) -> Self
Add a policy to this table
Sourcepub fn add_policies(self, policies: Vec<Policy>) -> Self
pub fn add_policies(self, policies: Vec<Policy>) -> Self
Add multiple policies to this table
Sourcepub fn is_rls_enabled(&self) -> bool
pub fn is_rls_enabled(&self) -> bool
Check if RLS is enabled
Sourcepub fn generate_rls_ddl(&self) -> String
pub fn generate_rls_ddl(&self) -> String
Generate RLS DDL for this table
Trait Implementations§
Source§impl IgnisObject for Table
impl IgnisObject for Table
impl StructuralPartialEq for Table
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
impl UnwindSafe for Table
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