marsdb_query/result.rs
1use crate::value::Value;
2
3#[derive(Debug, Clone, Default)]
4pub struct QueryResult {
5 pub columns: Vec<String>,
6 pub rows: Vec<Vec<Value>>,
7 /// What the statement changed — the answer to "how many did my
8 /// DELETE delete", which was previously unanswerable at any layer
9 /// (every write statement reported only its RETURN rows, usually
10 /// none). All-zero for read-only statements.
11 pub stats: QueryStats,
12}
13
14/// Per-statement write counters, following the widely-used summary-
15/// counter conventions: `properties_set` counts removals too (removing
16/// a property is setting it away, and `SET n.p = null` is literally the
17/// same operation as `REMOVE n.p` here), while label changes are
18/// tracked as their own pair.
19#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
20pub struct QueryStats {
21 pub nodes_created: u64,
22 pub nodes_deleted: u64,
23 pub relationships_created: u64,
24 pub relationships_deleted: u64,
25 pub properties_set: u64,
26 pub labels_added: u64,
27 pub labels_removed: u64,
28}
29
30impl QueryStats {
31 /// True when the statement changed nothing — lets output layers
32 /// (the CLI, the C ABI's JSON) skip stats noise for pure reads.
33 pub fn is_empty(&self) -> bool {
34 *self == Self::default()
35 }
36}