pub struct Table {
pub schema: String,
pub name: String,
pub description: Option<String>,
pub is_view: bool,
pub is_partitioned: bool,
pub insertable: bool,
pub updatable: bool,
pub deletable: bool,
pub pk_cols: Vec<String>,
pub unique_constraints: Vec<(String, Vec<String>)>,
pub columns: ColumnMap,
pub computed_columns: HashMap<String, ComputedColumn>,
}Expand description
A database table or view.
Fields§
§schema: StringSchema name
name: StringTable/view name
description: Option<String>Description from comment
is_view: boolWhether this is a view (vs a table)
is_partitioned: boolWhether this is a partitioned table.
It behaves as a table for reading and writing, but not for everything:
a system column such as xmax cannot be read back from one.
insertable: boolWhether INSERT is allowed
updatable: boolWhether UPDATE is allowed
deletable: boolWhether DELETE is allowed
pk_cols: Vec<String>Primary key column names
unique_constraints: Vec<(String, Vec<String>)>Unique constraints, as (name, columns), the primary key among them.
Named because ON CONFLICT ON CONSTRAINT takes a name: an upsert has
to say which uniqueness it is resolving against, and a table may have
several.
columns: ColumnMapColumns indexed by name
computed_columns: HashMap<String, ComputedColumn>Computed columns, indexed by name.
Not part of the table, and never returned by select=*: a function of
one argument of the table’s own row type, which PostgreSQL lets a query
read as though it were a column. PostgREST exposes them under the name
the function has, so ?select=id,always_true and ?always_true=is.true
both work on a table that has no such column.
Implementations§
Source§impl Table
impl Table
Sourcepub fn get_column(&self, name: &str) -> Option<&Column>
pub fn get_column(&self, name: &str) -> Option<&Column>
Get a column by name.
Sourcepub fn get_computed_column(&self, name: &str) -> Option<&ComputedColumn>
pub fn get_computed_column(&self, name: &str) -> Option<&ComputedColumn>
Get a computed column by name.
Sourcepub fn has_column(&self, name: &str) -> bool
pub fn has_column(&self, name: &str) -> bool
Check if the table has a column.
Sourcepub fn qualified_identifier(&self) -> QualifiedIdentifier
pub fn qualified_identifier(&self) -> QualifiedIdentifier
Get the qualified identifier for this table.
Sourcepub fn column_names(&self) -> impl Iterator<Item = &str>
pub fn column_names(&self) -> impl Iterator<Item = &str>
Get column names in order.
Sourcepub fn is_readonly(&self) -> bool
pub fn is_readonly(&self) -> bool
Check if this is a read-only view.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Table
impl<'de> Deserialize<'de> for Table
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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> ⓘ
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