toasty_driver_integration_suite/scenarios/
has_many_unique_title.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: uuid::Uuid,
22
23 #[belongs_to(key = user_id, references = id)]
24 user: toasty::Deferred<User>,
25
26 #[unique]
27 title: String,
28 }
29
30 async fn setup(test: &mut Test) -> toasty::Db {
31 test.setup_db(models!(User, Todo)).await
32 }
33}