ordinary-config 0.11.1

Config for Ordinary
Documentation
// Copyright (C) 2026 The Ordinary Authors.
//
// SPDX-License-Identifier: BSD-3-Clause

use ordinary_types::Field;
use serde::{Deserialize, Serialize};

#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[cfg_attr(feature = "docs", derive(schemars::JsonSchema))]
#[derive(Deserialize, Serialize, Debug, Clone, Default)]
pub struct DatabaseConfig {
    /// model definitions for the app database
    pub models: Vec<DatabaseModelConfig>,
    /// path to JSON formatted seeds file
    pub seeds_path: Option<String>,
}

/// Defines a model in the Ordinary Database.
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[cfg_attr(feature = "docs", derive(schemars::JsonSchema))]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct DatabaseModelConfig {
    /// Index of the model. Used for its kind
    /// for storage keys. There can be no gaps in
    /// index values.
    ///
    /// Note: the first (0) index is always skipped as it
    /// is reserved for the item UUID.
    pub idx: u8,
    /// Name of the model.
    pub name: String,
    /// Fields on the model.
    pub fields: Vec<Field>,
    /// Every model is generated with a UUID key. If this value
    /// is blank, it will default to V4. If you'd like records to
    /// be ordered by time, V7 is recommended.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub uuid: Option<UuidVersion>,
}

#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[cfg_attr(feature = "docs", derive(schemars::JsonSchema))]
#[derive(Deserialize, Serialize, Debug, Clone, Default)]
pub enum UuidVersion {
    V4,
    #[default]
    V7,
}