use surrealdb::types::{Datetime, SurrealValue};
/// A user (`user:<id>`), known by their email: they sign in with a code sent
/// there, or a passkey. No passwords are stored.
/// Deleting a user deletes their roles and memberships (see the migration).
#[derive(Debug, Clone, SurrealValue)]
pub struct User {
/// From the `user_id` sequence, never reused, so stale references cannot
/// point at someone else.
pub id: i64,
pub email: Option<String>,
pub name: String,
pub created_at: Datetime,
}
impl User {
/// What to select for this struct: every field, with the numeric `id`,
/// e.g. `SELECT {FIELDS} FROM user WHERE ...`.
pub const FIELDS: &str = "*, record::id(id) AS id";
}