sqlorm_core/qb/additions/
joins.rs

1use crate::{QB, TableInfo};
2
3#[derive(Clone, Debug)]
4/// Join type for related tables.
5pub enum JoinType {
6    Inner,
7    Left,
8}
9
10#[derive(Clone, Debug)]
11/// Specification for joining a related table.
12pub struct JoinSpec {
13    /// The join type.
14    pub join_type: JoinType,
15    /// Relation name.
16    pub relation_name: &'static str,
17    /// The joined table metadata.
18    pub foreign_table: TableInfo,
19    /// Join key mapping as (base_pk, foreign_fk).
20    pub on: (&'static str, &'static str),
21}
22
23impl<T> QB<T> {
24    pub fn join_eager(mut self, spec: JoinSpec) -> Self {
25        self.eager.push(spec);
26        self
27    }
28
29    pub fn join_batch(mut self, spec: JoinSpec) -> Self {
30        self.batch.push(spec);
31        self
32    }
33}