pub struct ModelDecl {
pub name: Ident,
pub fields: Vec<FieldDecl>,
pub attributes: Vec<ModelAttribute>,
pub span: Span,
}Expand description
A model block declaration.
§Example
model User {
id Int @id @default(autoincrement())
email String @unique
@@map("users")
}Fields§
§name: IdentThe model name (e.g., “User”).
fields: Vec<FieldDecl>Field declarations.
attributes: Vec<ModelAttribute>Model-level attributes (@@map, @@id, etc.).
span: SpanSpan covering the entire model block.
Implementations§
Source§impl ModelDecl
impl ModelDecl
Sourcepub fn find_field(&self, name: &str) -> Option<&FieldDecl>
pub fn find_field(&self, name: &str) -> Option<&FieldDecl>
Finds a field by name.
Sourcepub fn table_name(&self) -> &str
pub fn table_name(&self) -> &str
Gets the physical table name from @@map attribute, or the model name.
Sourcepub fn has_composite_key(&self) -> bool
pub fn has_composite_key(&self) -> bool
Checks if this model has a composite primary key (@@id).
Sourcepub fn relation_fields(&self) -> impl Iterator<Item = &FieldDecl>
pub fn relation_fields(&self) -> impl Iterator<Item = &FieldDecl>
Returns all fields that are part of relations. This includes fields with user-defined types (model/enum references).
Trait Implementations§
impl StructuralPartialEq for ModelDecl
Auto Trait Implementations§
impl Freeze for ModelDecl
impl RefUnwindSafe for ModelDecl
impl Send for ModelDecl
impl Sync for ModelDecl
impl Unpin for ModelDecl
impl UnsafeUnpin for ModelDecl
impl UnwindSafe for ModelDecl
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