toasty_core/schema/app/pk.rs
1use super::{FieldId, IndexId};
2
3/// The primary key definition for a root model.
4///
5/// A primary key consists of one or more fields that uniquely identify a
6/// record, plus a reference to the backing [`Index`](super::Index).
7///
8/// # Examples
9///
10/// ```
11/// use toasty_core::schema::app::{PrimaryKey, IndexId, ModelId};
12///
13/// let pk = PrimaryKey {
14/// fields: vec![ModelId(0).field(0)],
15/// index: IndexId { model: ModelId(0), index: 0 },
16/// };
17/// assert_eq!(pk.fields.len(), 1);
18/// ```
19#[derive(Debug, Clone)]
20pub struct PrimaryKey {
21 /// The fields that compose this primary key, in order.
22 pub fields: Vec<FieldId>,
23
24 /// The [`IndexId`] of the index backing this primary key.
25 pub index: IndexId,
26}