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