use crate::prelude::*;
scenario! {
#![id(ID)]
#[derive(Debug, toasty::Model)]
struct User {
#[key]
#[auto]
id: ID,
name: String,
#[has_many]
todos: toasty::HasMany<Todo>,
}
#[derive(Debug, toasty::Model)]
struct Todo {
#[key]
#[auto]
id: ID,
#[index]
user_id: ID,
#[belongs_to(key = user_id, references = id)]
user: toasty::BelongsTo<User>,
#[index]
category_id: ID,
#[belongs_to(key = category_id, references = id)]
category: toasty::BelongsTo<Category>,
title: String,
}
#[derive(Debug, toasty::Model)]
struct Category {
#[key]
#[auto]
id: ID,
name: String,
#[has_many]
todos: toasty::HasMany<Todo>,
}
async fn setup(test: &mut Test) -> toasty::Db {
test.setup_db(models!(User, Todo, Category)).await
}
}