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>

source

pub fn field_id(self) -> FieldId

The ID of the field node in the AST.

source

pub fn ast_field(self) -> &'db Field

The field node in the AST.

source

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.
source

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

The name of the field.

source

pub fn default_attribute(self) -> Option<&'db Attribute>

The @default() AST attribute on the field, if any.

source

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

The final database name of the field. See crate docs for explanations on database names.

source

pub fn is_autoincrement(self) -> bool

Does the field have an @default(autoincrement()) attribute?

source

pub fn is_single_pk(self) -> bool

Does the field define a primary key by its own.

source

pub fn is_part_of_a_compound_pk(self) -> bool

Is the field part of a compound primary key.

source

pub fn is_ignored(self) -> bool

Is there an @ignore attribute on the field?

source

pub fn is_optional(self) -> bool

Is the field optional / nullable?

source

pub fn is_list(self) -> bool

Is the field a list

source

pub fn is_updated_at(self) -> bool

Is there an @updatedAt attribute on the field?

source

pub fn field_type_as_enum(self) -> Option<EnumWalker<'db>>

Is this field’s type an enum? If yes, walk the enum.

source

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

The name in the @map(<name>) attribute.

source

pub fn model(self) -> ModelWalker<'db>

The model that contains the field.

source

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”, &[], )

source

pub fn is_unsupported(self) -> bool

Is the type of the field Unsupported("...")?

source

pub fn default_value(self) -> Option<DefaultValueWalker<'db>>

The @default() attribute of the field, if any.

source

pub fn scalar_field_type(self) -> ScalarFieldType

The type of the field.

source

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).