(db: &DbConn)
| 68 | } |
| 69 | |
| 70 | async fn find_one_to_one(db: &DbConn) -> Result<(), DbErr> { |
| 71 | print!("find fruits and cakes: "); |
| 72 | |
| 73 | let fruits_and_cakes: Vec<(fruit::Model, Option<cake::Model>)> = |
| 74 | Fruit::find().find_also_related(Cake).all(db).await?; |
| 75 | |
| 76 | println!("with loader: "); |
| 77 | let fruits: Vec<fruit::Model> = Fruit::find().all(db).await?; |
| 78 | let cakes: Vec<Option<cake::Model>> = fruits.load_one(Cake, db).await?; |
| 79 | |
| 80 | println!(); |
| 81 | for (left, right) in fruits_and_cakes |
| 82 | .into_iter() |
| 83 | .zip(fruits.into_iter().zip(cakes.into_iter())) |
| 84 | { |
| 85 | println!("{left:?}"); |
| 86 | assert_eq!(left, right); |
| 87 | } |
| 88 | |
| 89 | Ok(()) |
| 90 | } |
| 91 | |
| 92 | async fn find_one_to_many(db: &DbConn) -> Result<(), DbErr> { |
| 93 | print!("find cakes with fruits: "); |
no test coverage detected