toasty_driver_integration_suite/scenarios/
has_many_belongs_to.rs1use crate::prelude::*;
2
3scenario! {
4 #![id(ID)]
5
6 #[derive(Debug, toasty::Model)]
7 struct User {
8 #[key]
9 #[auto]
10 id: ID,
11
12 name: String,
13
14 #[has_many]
15 todos: toasty::HasMany<Todo>,
16 }
17
18 #[derive(Debug, toasty::Model)]
19 struct Todo {
20 #[key]
21 #[auto]
22 id: ID,
23
24 #[index]
25 user_id: ID,
26
27 #[belongs_to(key = user_id, references = id)]
28 user: toasty::BelongsTo<User>,
29
30 title: String,
31 }
32
33 async fn setup(test: &mut Test) -> toasty::Db {
34 test.setup_db(models!(User, Todo)).await
35 }
36}