aarondb/q
Types
pub type QueryBuilder {
QueryBuilder(
find: List(String),
clauses: List(ast.BodyClause),
order_by: option.Option(ast.OrderBy),
limit: option.Option(Int),
offset: option.Option(Int),
)
}
Constructors
-
QueryBuilder( find: List(String), clauses: List(ast.BodyClause), order_by: option.Option(ast.OrderBy), limit: option.Option(Int), offset: option.Option(Int), )
Values
pub fn avg(
builder: QueryBuilder,
into: String,
target: String,
filter: List(ast.BodyClause),
) -> QueryBuilder
Avg aggregate
pub fn betweenness_centrality(
builder: QueryBuilder,
edge: String,
entity_var: String,
score_var: String,
) -> QueryBuilder
Calculate betweenness centrality (Brandes’ algorithm) for each node.
pub fn cognitive(
builder: QueryBuilder,
concept: ast.Part,
context: ast.Part,
threshold: Float,
engram_var: String,
) -> QueryBuilder
Semantic cognitive search over stored concept, context, and relevance facts.
pub fn connected_components(
builder: QueryBuilder,
edge: String,
entity_var: String,
component_var: String,
) -> QueryBuilder
Label each node with a connected component ID.
pub fn count(
builder: QueryBuilder,
into: String,
target: String,
filter: List(ast.BodyClause),
) -> QueryBuilder
Count aggregate
pub fn cycle_detect(
builder: QueryBuilder,
edge: String,
cycle_var: String,
) -> QueryBuilder
Detect cycles in directed graph. Each result binds a List of entity refs forming a cycle.
pub fn filter(
builder: QueryBuilder,
expr: ast.Expression,
) -> QueryBuilder
Generic filter expression.
pub fn from_clauses(
clauses: List(ast.BodyClause),
) -> QueryBuilder
pub fn max(
builder: QueryBuilder,
into: String,
target: String,
filter: List(ast.BodyClause),
) -> QueryBuilder
Max aggregate
pub fn median(
builder: QueryBuilder,
into: String,
target: String,
filter: List(ast.BodyClause),
) -> QueryBuilder
Median aggregate
pub fn min(
builder: QueryBuilder,
into: String,
target: String,
filter: List(ast.BodyClause),
) -> QueryBuilder
Min aggregate
pub fn negate(
builder: QueryBuilder,
entity: ast.Part,
attr: String,
value: ast.Part,
) -> QueryBuilder
Add a negative where clause (Entity, Attribute, Value).
pub fn neighbors(
builder: QueryBuilder,
from: ast.Part,
edge: String,
depth: Int,
node_var: String,
) -> QueryBuilder
Find all nodes within K hops of a starting node.
pub fn new() -> QueryBuilder
pub fn order_by(
builder: QueryBuilder,
variable: String,
direction: ast.OrderDirection,
) -> QueryBuilder
Order results
pub fn pagerank(
builder: QueryBuilder,
entity_var: String,
edge: String,
rank_var: String,
damping damping: Float,
iterations iterations: Int,
) -> QueryBuilder
Calculate PageRank for nodes connected by an edge.
pub fn pull(
builder: QueryBuilder,
variable: String,
entity: ast.Part,
pattern: List(ast.PullItem),
) -> QueryBuilder
Pull attributes for an entity into a variable.
pub fn reachable(
builder: QueryBuilder,
from: ast.Part,
edge: String,
node_var: String,
) -> QueryBuilder
Find all nodes reachable from a starting node.
pub fn select(vars: List(String)) -> QueryBuilder
pub fn shortest_path(
builder: QueryBuilder,
from: ast.Part,
to: ast.Part,
edge: String,
path_var: String,
cost_var cost_var: option.Option(String),
max_depth max_depth: option.Option(Int),
) -> QueryBuilder
Find the shortest path between two entities via an edge attribute.
pub fn similar(
builder: QueryBuilder,
variable: String,
vector: List(Float),
threshold: Float,
) -> QueryBuilder
Vector similarity search: binds variable to entities whose stored vector
is within threshold of vector, resolved by the engine’s vector/HNSW
index. (Previously this emitted a value-equality Positive clause — a
placeholder — now it emits the real ast.Similarity clause.)
pub fn since(
builder: QueryBuilder,
variable: String,
val: ast.Part,
) -> QueryBuilder
Filter results since a specific value (exclusive)
pub fn sum(
builder: QueryBuilder,
into: String,
target: String,
filter: List(ast.BodyClause),
) -> QueryBuilder
Sum aggregate
pub fn temporal_at(
builder: QueryBuilder,
variable: String,
entity: ast.Part,
tx: Int,
) -> QueryBuilder
Bind variable to the transaction-time basis used by nested clauses.
This is an exact At query: nested clauses observe only datoms whose
transaction id is at most tx. For a complete query-level snapshot API,
prefer aarondb.as_of_tx.
pub fn to_clauses(builder: QueryBuilder) -> List(ast.BodyClause)
Convert builder to a list of clauses for backwards compatibility. NOTE: This will lose find/limit/offset/order info.
pub fn topological_sort(
builder: QueryBuilder,
edge: String,
entity_var: String,
order_var: String,
) -> QueryBuilder
Topological ordering of a DAG. Returns empty if cycles exist.
pub fn valid_temporal_at(
builder: QueryBuilder,
variable: String,
entity: ast.Part,
valid_time: Int,
) -> QueryBuilder
Bind variable to the valid-time basis used by nested clauses.
This is an exact At query: nested clauses observe only datoms whose
valid time is at most valid_time. For a complete query-level snapshot API,
prefer aarondb.as_of_valid.
pub fn virtual(
builder: QueryBuilder,
predicate: String,
args: List(ast.Part),
outputs: List(String),
) -> QueryBuilder
Query an external data source (Virtual Predicate).
pub fn where(
builder: QueryBuilder,
entity: ast.Part,
attr: String,
value: ast.Part,
) -> QueryBuilder
Add a where clause (Entity, Attribute, Value).