Skip to main content

rustauth_core/options/
model_schema.rs

1//! Per-model schema alias options (parity with Better Auth `modelName` / `fields`).
2
3use std::collections::BTreeMap;
4
5/// Table and column alias overrides for a core auth model.
6#[derive(Debug, Clone, Default, PartialEq, Eq)]
7pub struct ModelSchemaOptions {
8    /// Physical database table name override.
9    pub model_name: Option<String>,
10    /// Logical field name to physical column name aliases.
11    pub field_names: BTreeMap<String, String>,
12}
13
14impl ModelSchemaOptions {
15    pub fn new() -> Self {
16        Self::default()
17    }
18
19    #[must_use]
20    pub fn model_name(mut self, name: impl Into<String>) -> Self {
21        self.model_name = Some(name.into());
22        self
23    }
24
25    #[must_use]
26    pub fn field_name(
27        mut self,
28        logical_name: impl Into<String>,
29        db_name: impl Into<String>,
30    ) -> Self {
31        self.field_names.insert(logical_name.into(), db_name.into());
32        self
33    }
34}