pub struct TableDef {
pub name: String,
pub fields: Vec<FieldDef>,
pub primary_key: Vec<String>,
pub foreign_keys: Vec<ForeignKey>,
}Expand description
One declared table.
Fields§
§name: StringLowercase snake-case identifier, unique within the schema.
fields: Vec<FieldDef>Columns, in declaration order. That order is the column order of the generated DDL and the order errors are reported in.
primary_key: Vec<String>One or more declared field names. Primary-key fields are NOT NULL whether or not they are marked required.
foreign_keys: Vec<ForeignKey>Implementations§
Source§impl TableDef
impl TableDef
Sourcepub fn new(
name: impl Into<String>,
primary_key: impl Into<String>,
fields: Vec<FieldDef>,
) -> Self
pub fn new( name: impl Into<String>, primary_key: impl Into<String>, fields: Vec<FieldDef>, ) -> Self
A table with a single-column primary key.
pub fn foreign_key(self, key: ForeignKey) -> Self
Sourcepub fn field(&self, name: &str) -> Option<&FieldDef>
pub fn field(&self, name: &str) -> Option<&FieldDef>
The declared field called name, if there is one.
Sourcepub fn is_primary_key(&self, name: &str) -> bool
pub fn is_primary_key(&self, name: &str) -> bool
Whether name is part of the primary key.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TableDef
impl<'de> Deserialize<'de> for TableDef
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for TableDef
Auto Trait Implementations§
impl Freeze for TableDef
impl RefUnwindSafe for TableDef
impl Send for TableDef
impl Sync for TableDef
impl Unpin for TableDef
impl UnsafeUnpin for TableDef
impl UnwindSafe for TableDef
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