use surrealdb::types::{Datetime, SurrealValue};
/// An invitation (`invitation:<id>`) to join a team, by email. The invitee
/// accepts it after signing in (or signing up) with that email, verified by
/// the provider; it is deleted once accepted, declined or revoked.
#[derive(Debug, Clone, SurrealValue)]
pub struct Invitation {
pub id: i64,
pub team_id: i64,
/// Lowercased; one invitation per team and email.
pub email: String,
/// The role the invitee gets: `owner`, `admin` or `staff`.
pub role: String,
/// For `staff`: their modules, comma-separated.
pub modules: String,
/// Who sent it (a user id).
pub invited_by: i64,
pub created_at: Datetime,
}
impl Invitation {
/// What to select for this struct: every field, with the numeric `id`,
/// e.g. `SELECT {FIELDS} FROM invitation WHERE ...`.
pub const FIELDS: &str = "*, record::id(id) AS id";
}