1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use ;
/// A foreign key linking one model's fields to another model's primary key.
///
/// A `ForeignKey` is composed of one or more [`ForeignKeyField`] pairs, each
/// mapping a source field (on the owning model) to a target field (on the
/// referenced model). For single-column primary keys the `fields` vec has one
/// entry; composite keys have multiple.
///
/// # Examples
///
/// ```
/// use toasty_core::schema::app::{ForeignKey, ForeignKeyField, FieldId, ModelId};
///
/// let fk = ForeignKey {
/// fields: vec![ForeignKeyField {
/// source: ModelId(0).field(1),
/// target: ModelId(1).field(0),
/// }],
/// };
/// assert_eq!(fk.fields.len(), 1);
/// ```
/// One column-pair within a [`ForeignKey`].
///
/// Maps a single field on the source (owning) model to the corresponding
/// field on the target (referenced) model.
///
/// # Examples
///
/// ```
/// use toasty_core::schema::app::{ForeignKeyField, ModelId};
///
/// let fkf = ForeignKeyField {
/// source: ModelId(0).field(2),
/// target: ModelId(1).field(0),
/// };
/// ```