MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / find_one_to_one

Function find_one_to_one

examples/basic/src/select.rs:70–90  ·  view source on GitHub ↗
(db: &DbConn)

Source from the content-addressed store, hash-verified

68}
69
70async 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
92async fn find_one_to_many(db: &DbConn) -> Result<(), DbErr> {
93 print!("find cakes with fruits: ");

Callers 1

all_about_selectFunction · 0.85

Calls 4

find_also_relatedMethod · 0.80
load_oneMethod · 0.80
into_iterMethod · 0.80
allMethod · 0.45

Tested by

no test coverage detected