ic_db_cli/relations.rs
1//! Relation contract shared by the local server and its bundled qualification fixture.
2//! Decimal strings preserve all 64-bit values when the server returns JSON.
3use serde::{Deserialize, Serialize};
4
5/// An entry returned by a fixture lookup or included with a document.
6#[derive(Serialize, Deserialize)]
7pub struct EntryRow {
8 /// Primary key as a decimal string.
9 pub id: String,
10 /// Entry category as a decimal string.
11 pub category: String,
12 /// Entry amount as a decimal string.
13 pub amount: String,
14}
15
16/// A document and its optionally included entry.
17#[derive(Serialize, Deserialize)]
18pub struct DocumentRow {
19 /// Primary key as a decimal string.
20 pub id: String,
21 /// Primary key of the referenced entry as a decimal string.
22 pub entry_id: String,
23 /// Document title.
24 pub title: String,
25 /// Optional document note.
26 pub note: Option<String>,
27 /// Whether the document is published.
28 pub published: bool,
29 /// Current score as a decimal string.
30 pub score: String,
31 /// Previous score, when recorded.
32 pub previous_score: Option<String>,
33 /// Priority, when assigned.
34 pub priority: Option<String>,
35 /// Referenced entry when requested.
36 pub entry: Option<EntryRow>,
37}
38
39/// One page from the document relation query.
40#[derive(Serialize, Deserialize)]
41pub struct DocumentPage {
42 /// Documents in query order.
43 pub rows: Vec<DocumentRow>,
44 /// Opaque cursor for the next page.
45 pub next: Option<Vec<u8>>,
46}
47
48/// Selection and pagination for the document relation query.
49#[derive(Serialize, Deserialize)]
50pub struct Documents {
51 /// Restrict results to this entry when supplied.
52 pub entry_id: Option<u64>,
53 /// Opaque cursor returned by the previous page.
54 pub after: Option<Vec<u8>>,
55 /// Maximum number of documents requested.
56 pub take: u8,
57 /// Whether to fetch each referenced entry.
58 pub include_entry: bool,
59}