toasty_driver_integration_suite/scenarios/
composite_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 #[index]
13 name: String,
14
15 #[has_many]
16 todos: toasty::HasMany<Todo>,
17 }
18
19 #[derive(Debug, toasty::Model)]
20 #[key(partition = user_id, local = id)]
21 struct Todo {
22 #[auto]
23 id: uuid::Uuid,
24
25 user_id: ID,
26
27 #[belongs_to(key = user_id, references = id)]
28 user: toasty::BelongsTo<User>,
29
30 #[index]
31 title: String,
32 }
33
34 async fn setup(test: &mut Test) -> toasty::Db {
35 test.setup_db(models!(User, Todo)).await
36 }
37}