pub type RelationWalker<'db> = Walker<'db, RelationId>;
Expand description

A relation that has the minimal amount of information for us to create one. Useful for validation purposes. Holds all possible relation types.

Aliased Type§

struct RelationWalker<'db> {
    pub db: &'db ParserDatabase,
    pub id: RelationId,
}

Fields§

§db: &'db ParserDatabase

The parser database being traversed.

§id: RelationId

The identifier of the focused element.

Implementations§

source§

impl<'db> RelationWalker<'db>

source

pub fn models(self) -> [ModelId; 2]

The models at each end of the relation. [model A, model B]. Can be the same model twice.

source

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

The relation fields that define the relation. A then B.

source

pub fn is_ignored(self) -> bool

Is any field part of the relation ignored (@ignore) or unsupported?

source

pub fn is_self_relation(self) -> bool

Is this a relation where both ends are the same model?

source

pub fn refine(self) -> RefinedRelationWalker<'db>

Converts the walker to either an implicit many to many, or a inline relation walker gathering 1:1 and 1:n relations.

source

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

The relation name in the schema.

myField OtherModel @relation("thisModelToOtherModel", fields: [fkfield], references: [id])
//                           ^^^^^^^^^^^^^^^^^^^^^^^
source

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

The relation name, explicit or inferred.

posts Post[] @relation("UserPosts")
                       ^^^^^^^^^^^