pub type ModelWalker<'db> = Walker<'db, ModelId>;
Expand description

A model declaration in the Prisma schema.

Aliased Type§

struct ModelWalker<'db> {
    pub db: &'db ParserDatabase,
    pub id: ModelId,
}

Fields§

§db: &'db ParserDatabase

The parser database being traversed.

§id: ModelId

The identifier of the focused element.

Implementations§

source§

impl<'db> ModelWalker<'db>

source

pub fn name(self) -> &'db str

The name of the model.

source

pub fn fields(self) -> impl ExactSizeIterator<Item = FieldWalker<'db>> + Clone

Traverse the fields of the models in the order they were defined.

source

pub fn field_is_indexed_for_autoincrement(self, field_id: FieldId) -> bool

Whether MySQL would consider the field indexed for autoincrement purposes.

source

pub fn field_is_single_pk(self, field: FieldId) -> bool

Whether the field is the whole primary key. Will match @id and @@id([fieldName]).

source

pub fn field_is_part_of_a_compound_pk(self, field: FieldId) -> bool

Is the field part of a compound primary key.

source

pub fn model_id(self) -> ModelId

The ID of the model in the db

source

pub fn ast_model(self) -> &'db Model

The AST node.

source

pub fn is_ignored(self) -> bool

Model has the @@ignore attribute.

source

pub fn database_name(self) -> &'db str

The name of the database table the model points to.

source

pub fn has_single_id_field(self) -> bool

Used in validation. True only if the model has a single field id.

source

pub fn mapped_name(self) -> Option<&'db str>

The name in the @@map attribute.

source

pub fn primary_key(self) -> Option<PrimaryKeyWalker<'db>>

The primary key of the model, if defined.

source

pub fn scalar_fields( self ) -> impl Iterator<Item = ScalarFieldWalker<'db>> + Clone

Iterate all the scalar fields in a given model in the order they were defined.

source

pub fn unique_criterias(self) -> impl Iterator<Item = UniqueCriteriaWalker<'db>>

All unique criterias of the model; consisting of the primary key and unique indexes, if set.

source

pub fn required_unique_criterias( self ) -> impl Iterator<Item = UniqueCriteriaWalker<'db>>

All required unique criterias of the model; consisting of the primary key and unique indexes, if set.

source

pub fn indexes(self) -> impl Iterator<Item = IndexWalker<'db>>

Iterate all the indexes in the model in the order they were defined.

source

pub fn relation_fields( self ) -> impl Iterator<Item = RelationFieldWalker<'db>> + Clone + 'db

All (concrete) relation fields of the model.

source

pub fn relations_from(self) -> impl Iterator<Item = RelationWalker<'db>>

All relations that start from this model.

source

pub fn relations_to(self) -> impl Iterator<Item = RelationWalker<'db>>

All relations that reference this model.

source

pub fn inline_relations_from( self ) -> impl Iterator<Item = InlineRelationWalker<'db>>

1:n and 1:1 relations that start from this model.

source

pub fn complete_inline_relations_from( self ) -> impl Iterator<Item = CompleteInlineRelationWalker<'db>>

1:n and 1:1 relations, starting from this model and having both sides defined.

source

pub fn indentation(self) -> IndentationType

How fields and arguments are indented in the model.

source

pub fn newline(self) -> NewlineType

What kind of newlines the model uses.

source

pub fn schema(self) -> Option<(&'db str, Span)>

The name of the schema the model belongs to.

@@schema("public")
         ^^^^^^^^
source

pub fn schema_name(self) -> Option<&'db str>

The name of the schema the model belongs to.

@@schema("public")
         ^^^^^^^^