pub struct FindWithRelated<'a> { /* private fields */ }Expand description
find_with_related 关联查询构造器(JOIN 模式)
适合 1:1 / N:1 关联(BelongsTo / HasOne)。
对于 1:N 关联,JOIN 会导致主表行膨胀,应使用 find_with_related_eager_sql。
Implementations§
Source§impl<'a> FindWithRelated<'a>
impl<'a> FindWithRelated<'a>
Sourcepub fn new(
dialect: &'a dyn Dialect,
main_table: impl Into<String>,
related_table: impl Into<String>,
foreign_key: impl Into<String>,
primary_key: impl Into<String>,
left_join: bool,
) -> Result<Self, DbError>
pub fn new( dialect: &'a dyn Dialect, main_table: impl Into<String>, related_table: impl Into<String>, foreign_key: impl Into<String>, primary_key: impl Into<String>, left_join: bool, ) -> Result<Self, DbError>
创建关联查询构造器
dialect:方言引用main_table:主表名related_table:关联表名foreign_key:外键列名(在 related_table 中,指向 main_table.primary_key)primary_key:主表主键列名left_join:true = LEFT JOIN,false = INNER JOIN
Sourcepub fn where_cond(self, cond: impl Into<String>) -> Self
pub fn where_cond(self, cond: impl Into<String>) -> Self
追加 WHERE 条件(AND 连接)
Sourcepub fn order_desc(self, field: impl Into<String>) -> Self
pub fn order_desc(self, field: impl Into<String>) -> Self
追加 ORDER BY(DESC)
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for FindWithRelated<'a>
impl<'a> !UnwindSafe for FindWithRelated<'a>
impl<'a> Freeze for FindWithRelated<'a>
impl<'a> Send for FindWithRelated<'a>
impl<'a> Sync for FindWithRelated<'a>
impl<'a> Unpin for FindWithRelated<'a>
impl<'a> UnsafeUnpin for FindWithRelated<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more