Type Alias parser_database::walkers::ScalarFieldWalker
source · pub type ScalarFieldWalker<'db> = Walker<'db, ScalarFieldId>;
Expand description
A scalar field, as part of a model.
Aliased Type§
struct ScalarFieldWalker<'db> {
pub db: &'db ParserDatabase,
pub id: ScalarFieldId,
}
Fields§
§db: &'db ParserDatabase
The parser database being traversed.
id: ScalarFieldId
The identifier of the focused element.
Implementations§
source§impl<'db> ScalarFieldWalker<'db>
impl<'db> ScalarFieldWalker<'db>
sourcepub fn is_unique(self) -> bool
pub fn is_unique(self) -> bool
Is this field unique? This method will return true if:
- The field has an
@id
or@unique
attribute. - There is an
@@id
or@@unique
on the model that contains only this field.
sourcepub fn default_attribute(self) -> Option<&'db Attribute>
pub fn default_attribute(self) -> Option<&'db Attribute>
The @default()
AST attribute on the field, if any.
sourcepub fn database_name(self) -> &'db str
pub fn database_name(self) -> &'db str
The final database name of the field. See crate docs for explanations on database names.
sourcepub fn is_autoincrement(self) -> bool
pub fn is_autoincrement(self) -> bool
Does the field have an @default(autoincrement())
attribute?
sourcepub fn is_single_pk(self) -> bool
pub fn is_single_pk(self) -> bool
Does the field define a primary key by its own.
sourcepub fn is_part_of_a_compound_pk(self) -> bool
pub fn is_part_of_a_compound_pk(self) -> bool
Is the field part of a compound primary key.
sourcepub fn is_ignored(self) -> bool
pub fn is_ignored(self) -> bool
Is there an @ignore
attribute on the field?
sourcepub fn is_optional(self) -> bool
pub fn is_optional(self) -> bool
Is the field optional / nullable?
sourcepub fn is_updated_at(self) -> bool
pub fn is_updated_at(self) -> bool
Is there an @updatedAt
attribute on the field?
sourcepub fn field_type_as_enum(self) -> Option<EnumWalker<'db>>
pub fn field_type_as_enum(self) -> Option<EnumWalker<'db>>
Is this field’s type an enum? If yes, walk the enum.
sourcepub fn mapped_name(self) -> Option<&'db str>
pub fn mapped_name(self) -> Option<&'db str>
The name in the @map(<name>)
attribute.
sourcepub fn model(self) -> ModelWalker<'db>
pub fn model(self) -> ModelWalker<'db>
The model that contains the field.
sourcepub fn raw_native_type(
self
) -> Option<(&'db str, &'db str, &'db [String], Span)>
pub fn raw_native_type( self ) -> Option<(&'db str, &'db str, &'db [String], Span)>
(attribute scope, native type name, arguments, span)
For example: @db.Text
would translate to (“db”, “Text”, &[],
sourcepub fn is_unsupported(self) -> bool
pub fn is_unsupported(self) -> bool
Is the type of the field Unsupported("...")
?
sourcepub fn default_value(self) -> Option<DefaultValueWalker<'db>>
pub fn default_value(self) -> Option<DefaultValueWalker<'db>>
The @default()
attribute of the field, if any.
sourcepub fn scalar_field_type(self) -> ScalarFieldType
pub fn scalar_field_type(self) -> ScalarFieldType
The type of the field.
sourcepub fn scalar_type(self) -> Option<ScalarType>
pub fn scalar_type(self) -> Option<ScalarType>
The type of the field in case it is a scalar type (not an enum, not a composite type).