2
2
3
3
## Foreign Keys
4
4
5
- You can use the type ` ForeignKey <T>` where ` T ` is any type that derives
5
+ You can use the type ` ForeignModel <T>` where ` T ` is any type that derives
6
6
also ` Model ` . It will create a reference to the primary key of the
7
7
model ` T ` .
8
8
@@ -15,7 +15,7 @@ struct Post {
15
15
#[rorm(id)]
16
16
id : i64 ,
17
17
18
- creator : ForeignKey <User >,
18
+ creator : ForeignModel <User >,
19
19
}
20
20
21
21
#[derive(Model )]
@@ -27,7 +27,7 @@ struct User {
27
27
28
28
!!! tip
29
29
30
- You can point a `ForeignKey <T>` to the `Model` its contained in to
30
+ You can point a `ForeignModel <T>` to the `Model` its contained in to
31
31
build self-refenencing structs.
32
32
33
33
```rust
@@ -38,13 +38,13 @@ struct User {
38
38
#[rorm(id)]
39
39
id: i64,
40
40
41
- creator: ForeignKey <Post>,
41
+ creator: ForeignModel <Post>,
42
42
}
43
43
```
44
44
45
45
### Foreign keys on non-primary keys
46
46
47
- With ` ForeignKey ` it is not possible to reference a non-primary key.
47
+ With ` ForeignModel ` it is not possible to reference a non-primary key.
48
48
In order to support this use case, the slightly more verbose
49
49
` ForeignModelByField<T> ` type was created.
50
50
@@ -59,7 +59,7 @@ struct Post {
59
59
#[rorm(id)]
60
60
id : i64 ,
61
61
62
- creator_aid : ForeignKeyByField <field ! (User :: F . another_id)>,
62
+ creator_aid : ForeignModelByField <field ! (User :: F . another_id)>,
63
63
}
64
64
65
65
#[derive(Model )]
@@ -76,7 +76,7 @@ struct User {
76
76
## Backrefs
77
77
78
78
A backref is the (virtual) reference to be able to query
79
- "all items of a specific model with a ` ForeignKey ` pointing to the model on
79
+ "all items of a specific model with a ` ForeignModel ` pointing to the model on
80
80
which the backref is defined on."
81
81
82
82
``` rust
0 commit comments