Database
Query Types
AQL provides several query classes that form a hierarchy of capabilities. Each class encapsulates a different aspect of database interactions, from full table access down to individual value manipulation.
Query Type Hierarchy
All query types inherit from StagedObject, which records operations as a pipeline of stages. The hierarchy is:
Query<T>
├── Datum<T>
│ └── SingleSelection<T>
└── Stream<T>
└── Selection<T>
└── Table<T>
ValueProxy<T> (used within query callbacks)
Common Features
All query types that extend Query<T> share these capabilities:
run()- Execute the query and return aPromise<T>with the result.then()-PromiseLikesupport, so queries can be awaited directly.cursor()- Return anAsyncGeneratorfor streaming results one at a time.[Symbol.asyncIterator]()- Enablefor await...ofloops over query results.
import { Schema } from "@antelopejs/interface-database";
// Execute a query explicitly
const result = await schema.instance().table("users").run();
// Await the query directly (uses PromiseLike)
const users = await schema.instance().table("users");
// Iterate with async generator
for await (const user of schema.instance().table("users")) {
console.log(user.name);
}
Available Query Types
- Table - Represents a database table with insert, get, getAll, and between operations
- Selection - A set of documents supporting update, replace, and delete
- SingleSelection - A single document with update, replace, delete, and change feed support
- Stream - A sequence of results with map, filter, join, group, aggregate, and sort operations
- Change Feeds - Real-time change notifications via the
changes()method - Query - The base class providing execution and async iteration
- Datum - A single value with field access, transformation, and lookup capabilities
- ValueProxy - Proxy for in-query value operations (arithmetic, string, date, array, object)