8000 docs: fix Rust Quick Start rule and entity-ID examples by adityamukho · Pull Request #893 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Documentation

- Fix the Rust Quick Start (#884): register recursive rule clauses in separate `execute()` calls and define the keyword entity IDs used by prepared queries. Clarify the entity ID in the prepared-query error example.
- Correct ordinary aggregate examples and lists (#777): v2 supports `count`, `count-distinct`, `sum`, `sum-distinct`, `min` and `max`; `avg` requires `:over`. Query behavior is unchanged.
- Retire production-readiness tracker #383 in favor of the v3.0.0 milestone, preserving its release gates there.

Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@ tx.commit()?;
// Time travel — query as of past transaction counter
db.execute("(query [:find ?age :as-of 1 :where [:alice :person/age ?age]])")?;

// Recursive rule — transitive reachability
db.execute(r#"(rule [(reachable ?a ?b) [?a :friend ?b]])
(rule [(reachable ?a ?b) [?a :friend ?m] (reachable ?m ?b)])"#)?;
// Recursive rule — register each clause with a separate execute() call
db.execute("(rule [(reachable ?a ?b) [?a :friend ?b]])")?;
db.execute("(rule [(reachable ?a ?b) [?a :friend ?m] (reachable ?m ?b)])")?;
db.execute("(query [:find ?friend :where (reachable :alice ?friend)])")?;

// Prepared statement — parse + plan once, execute many times
use minigraf::BindValue;
use minigraf::{BindValue, EntityId};
// Keywords map to UUIDv5 IDs in the OID namespace, including the leading colon.
let alice_id = EntityId::new_v5(&EntityId::NAMESPACE_OID, b":alice");
let bob_id = EntityId::new_v5(&EntityId::NAMESPACE_OID, b":bob");
let pq = db.prepare("(query [:find ?name :as-of $tx :where [$entity :person/name ?name]])")?;
let r1 = pq.execute(&[("tx", BindValue::TxCount(1)), ("entity", BindValue::Entity(alice_id))])?;
let r2 = pq.execute(&[("tx", BindValue::TxCount(2)), ("entity", BindValue::Entity(bob_id))])?;
Expand Down
1 change: 1 addition & 0 deletions docs/ERROR_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,7 @@ db.execute("(rule [(ancestor ?x ?y) [?x :parent ?y]])")?;
- Prepare the query and supply a value for every slot:

```rust
let alice_id = minigraf::EntityId::new_v5(&minigraf::EntityId::NAMESPACE_OID, b":alice");
let pq = db.prepare("(query [:find ?status :as-of $tx :valid-at $date \
:where [$entity :employment/status ?status]])")?;
let result = pq.execute(&[
Expand Down
Loading
0