pub type RelationFieldWalker<'db> = Walker<'db, RelationFieldId>;
Expand description

A relation field on a model in the schema.

Aliased Type§

struct RelationFieldWalker<'db> {
    pub db: &'db ParserDatabase,
    pub id: RelationFieldId,
}

Fields§

§db: &'db ParserDatabase

The parser database being traversed.

§id: RelationFieldId

The identifier of the focused element.

Implementations§

source§

impl<'db> RelationFieldWalker<'db>

source

pub fn one_side_is_view(self) -> bool

The relation starts or ends to a view.

source

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

The foreign key name of the relation (@relation(map: ...)).

source

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

The field name.

source

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

The AST node of the field.

source

pub fn explicit_on_delete(self) -> Option<ReferentialAction>

The onDelete argument on the relation.

source

pub fn explicit_on_delete_span(self) -> Option<Span>

The onDelete argument on the relation.

source

pub fn explicit_on_update(self) -> Option<ReferentialAction>

The onUpdate argument on the relation.

source

pub fn explicit_on_update_span(self) -> Option<Span>

The onUpdate argument on the relation.

source

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

The relation name explicitly written in the schema source.

source

pub fn is_ignored(self) -> bool

Is there an @ignore attribute on the field?

source

pub fn is_required(self) -> bool

Is the field required? (not optional, not list)

source

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

The model containing the field.

source

pub fn opposite_relation_field(self) -> Option<RelationFieldWalker<'db>>

A valid relation is defined by two relation fields. This method returns the other relation field in the same relation.

source

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

The @relation attribute in the field AST.

source

pub fn references_model(self, other: ModelId) -> bool

Does the relation field reference the passed in model?

source

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

The model referenced by the relation.

source

pub fn referenced_fields( self ) -> Option<impl ExactSizeIterator<Item = ScalarFieldWalker<'db>>>

The fields in the @relation(references: ...) argument.

source

pub fn relation(self) -> RelationWalker<'db>

The relation this field is part of.

source

pub fn relation_name(self) -> RelationName<'db>

The name of the relation. Either uses the name (or default) argument, or generates an implicit name.

source

pub fn referential_arity(self) -> FieldArity

The arity to enforce, based on the arity of the fields. If any referencing field is required, this will be required.

Prisma allows setting the relation field as optional, even if one of the underlying scalar fields is required. For the purpose of referential actions, we count the relation field required if any of the underlying fields is required.

source

pub fn references_singular_id_field(self) -> bool

Used for validation.

source

pub fn referencing_fields( self ) -> Option<impl ExactSizeIterator<Item = ScalarFieldWalker<'db>> + Clone>

The fields in the fields: [...] argument in the forward relation field.

source

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

The fields in the fields: [...] argument in the forward relation field.