toasty_core/schema/app/relation/
belongs_to.rs1use crate::{
2 schema::app::{FieldId, FieldTy, ForeignKey, Model, ModelId, Schema},
3 stmt,
4};
5
6#[derive(Debug, Clone)]
7pub struct BelongsTo {
8 pub target: ModelId,
10
11 pub expr_ty: stmt::Type,
14
15 pub pair: Option<FieldId>,
17
18 pub foreign_key: ForeignKey,
21}
22
23impl BelongsTo {
24 pub fn target<'a>(&self, schema: &'a Schema) -> &'a Model {
25 schema.model(self.target)
26 }
27}
28
29impl From<BelongsTo> for FieldTy {
30 fn from(value: BelongsTo) -> Self {
31 Self::BelongsTo(value)
32 }
33}