Type Alias parser_database::walkers::ModelWalker
source · 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>
impl<'db> ModelWalker<'db>
sourcepub fn fields(self) -> impl ExactSizeIterator<Item = FieldWalker<'db>> + Clone
pub fn fields(self) -> impl ExactSizeIterator<Item = FieldWalker<'db>> + Clone
Traverse the fields of the models in the order they were defined.
sourcepub fn field_is_indexed_for_autoincrement(self, field_id: FieldId) -> bool
pub fn field_is_indexed_for_autoincrement(self, field_id: FieldId) -> bool
Whether MySQL would consider the field indexed for autoincrement purposes.
sourcepub fn field_is_single_pk(self, field: FieldId) -> bool
pub fn field_is_single_pk(self, field: FieldId) -> bool
Whether the field is the whole primary key. Will match @id
and @@id([fieldName])
.
sourcepub fn field_is_part_of_a_compound_pk(self, field: FieldId) -> bool
pub fn field_is_part_of_a_compound_pk(self, field: FieldId) -> bool
Is the field part of a compound primary key.
sourcepub fn is_ignored(self) -> bool
pub fn is_ignored(self) -> bool
Model has the @@ignore attribute.
sourcepub fn database_name(self) -> &'db str
pub fn database_name(self) -> &'db str
The name of the database table the model points to.
sourcepub fn has_single_id_field(self) -> bool
pub fn has_single_id_field(self) -> bool
Used in validation. True only if the model has a single field id.
sourcepub fn mapped_name(self) -> Option<&'db str>
pub fn mapped_name(self) -> Option<&'db str>
The name in the @@map attribute.
sourcepub fn primary_key(self) -> Option<PrimaryKeyWalker<'db>>
pub fn primary_key(self) -> Option<PrimaryKeyWalker<'db>>
The primary key of the model, if defined.
sourcepub fn scalar_fields(
self
) -> impl Iterator<Item = ScalarFieldWalker<'db>> + Clone
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.
sourcepub fn unique_criterias(self) -> impl Iterator<Item = UniqueCriteriaWalker<'db>>
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.
sourcepub fn required_unique_criterias(
self
) -> impl Iterator<Item = UniqueCriteriaWalker<'db>>
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.
sourcepub fn indexes(self) -> impl Iterator<Item = IndexWalker<'db>>
pub fn indexes(self) -> impl Iterator<Item = IndexWalker<'db>>
Iterate all the indexes in the model in the order they were defined.
sourcepub fn relation_fields(
self
) -> impl Iterator<Item = RelationFieldWalker<'db>> + Clone + 'db
pub fn relation_fields( self ) -> impl Iterator<Item = RelationFieldWalker<'db>> + Clone + 'db
All (concrete) relation fields of the model.
sourcepub fn relations_from(self) -> impl Iterator<Item = RelationWalker<'db>>
pub fn relations_from(self) -> impl Iterator<Item = RelationWalker<'db>>
All relations that start from this model.
sourcepub fn relations_to(self) -> impl Iterator<Item = RelationWalker<'db>>
pub fn relations_to(self) -> impl Iterator<Item = RelationWalker<'db>>
All relations that reference this model.
sourcepub fn inline_relations_from(
self
) -> impl Iterator<Item = InlineRelationWalker<'db>>
pub fn inline_relations_from( self ) -> impl Iterator<Item = InlineRelationWalker<'db>>
1:n and 1:1 relations that start from this model.
sourcepub fn complete_inline_relations_from(
self
) -> impl Iterator<Item = CompleteInlineRelationWalker<'db>>
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.
sourcepub fn indentation(self) -> IndentationType
pub fn indentation(self) -> IndentationType
How fields and arguments are indented in the model.
sourcepub fn newline(self) -> NewlineType
pub fn newline(self) -> NewlineType
What kind of newlines the model uses.
sourcepub fn schema(self) -> Option<(&'db str, Span)>
pub fn schema(self) -> Option<(&'db str, Span)>
The name of the schema the model belongs to.
@@schema("public")
^^^^^^^^
sourcepub fn schema_name(self) -> Option<&'db str>
pub fn schema_name(self) -> Option<&'db str>
The name of the schema the model belongs to.
@@schema("public")
^^^^^^^^