Crate cqlite

source ·
Expand description

CQLite provides an embedded property graph database.

A Graph can store a number of nodes, as well as edges forming relationships between those nodes. Each node or edge has a set of zero or more key value pairs called properties.

The graph supports ACID queries using a simplified subset of the CYPHER graph query language, which can be run inside read-only or read-write transactions.

Example

use cqlite::Graph;

let graph = Graph::open_anon()?;

let mut txn = graph.mut_txn()?;
let edge: u64 = graph.prepare(
        "
        CREATE (a:PERSON { name: 'Peter Parker' })
        CREATE (b:PERSON { name: 'Clark Kent' })
        CREATE (a) -[e:KNOWS]-> (b)
        RETURN ID(e)
        "
    )?
    .query_map(&mut txn, (), |m| m.get(0))?
    .next()
    .unwrap()?;
txn.commit()?;

let name: String = graph.prepare(
        "
        MATCH (p:PERSON) <-[e:KNOWS]- (:PERSON)
        WHERE ID(e) = $edge
        RETURN p.name
        "
    )?
    .query_map(&mut graph.txn()?, ("edge", edge), |m| m.get(0))?
    .next()
    .unwrap()?;
assert_eq!("Clark Kent", name);

Structs

  • A graph is a collection of nodes and edges.
  • Iterator which yields all matches of the contained query after mapping them with a user provided function.
  • RAII guard which represents a set of nodes and edges matching a query.
  • RAII guard which represents an ongoing query.
  • A prepared statement.
  • An ongoing transaction.

Enums

  • Errors which can occur while interacting with a Graph.
  • A single property which can be stored on a node or edge.

Traits