pub struct ColumnDef {
pub name: String,
pub col_type: ColumnType,
pub nullable: bool,
pub primary_key: bool,
pub unique: bool,
pub default: Option<String>,
pub references: Option<ForeignKey>,
}Expand description
Describes one column in a table schema.
ColumnDef is produced by #[derive(Model)] from your struct fields
and consumed by each backend’s create_table implementation to emit
the appropriate DDL (CREATE TABLE for SQL, createCollection + indexes
for MongoDB).
You rarely construct these manually unless you are implementing a custom backend or building schemas programmatically.
Fields§
§name: String§col_type: ColumnType§nullable: bool§primary_key: bool§unique: bool§default: Option<String>§references: Option<ForeignKey>Implementations§
Source§impl ColumnDef
impl ColumnDef
pub fn new(name: impl Into<String>, col_type: ColumnType) -> Self
pub fn primary_key(self) -> Self
pub fn not_null(self) -> Self
pub fn unique(self) -> Self
pub fn default(self, expr: impl Into<String>) -> Self
pub fn references( self, table: impl Into<String>, column: impl Into<String>, ) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ColumnDef
impl RefUnwindSafe for ColumnDef
impl Send for ColumnDef
impl Sync for ColumnDef
impl Unpin for ColumnDef
impl UnsafeUnpin for ColumnDef
impl UnwindSafe for ColumnDef
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