(db: &DbConn)
| 90 | } |
| 91 | |
| 92 | async fn find_one_to_many(db: &DbConn) -> Result<(), DbErr> { |
| 93 | print!("find cakes with fruits: "); |
| 94 | |
| 95 | let cakes_with_fruits: Vec<(cake::Model, Vec<fruit::Model>)> = Cake::find() |
| 96 | .find_with_related(fruit::Entity) |
| 97 | .all(db) |
| 98 | .await?; |
| 99 | |
| 100 | println!("with loader: "); |
| 101 | let cakes: Vec<cake::Model> = Cake::find().all(db).await?; |
| 102 | let fruits: Vec<Vec<fruit::Model>> = cakes.load_many(Fruit, db).await?; |
| 103 | |
| 104 | println!(); |
| 105 | for (left, right) in cakes_with_fruits |
| 106 | .into_iter() |
| 107 | .zip(cakes.into_iter().zip(fruits.into_iter())) |
| 108 | { |
| 109 | println!("{left:?}\n"); |
| 110 | assert_eq!(left, right); |
| 111 | } |
| 112 | |
| 113 | Ok(()) |
| 114 | } |
| 115 | |
| 116 | impl Cake { |
| 117 | fn find_by_name(name: &str) -> Select<Self> { |
no test coverage detected