# 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 ├── Datum │ └── SingleSelection └── Stream └── Selection └── Table ValueProxy (used within query callbacks) ``` ## Common Features All query types that extend `Query` share these capabilities: - **`run()`** - Execute the query and return a `Promise` with the result. - **`then()`** - `PromiseLike` support, so queries can be awaited directly. - **`cursor()`** - Return an `AsyncGenerator` for streaming results one at a time. - **`[Symbol.asyncIterator]()`** - Enable `for await...of` loops over query results. ```typescript 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**](./2.table.md) - Represents a database table with insert, get, getAll, and between operations - [**Selection**](./3.selection.md) - A set of documents supporting update, replace, and delete - [**SingleSelection**](./4.single_selection.md) - A single document with update, replace, delete, and change feed support - [**Stream**](./5.stream.md) - A sequence of results with map, filter, join, group, aggregate, and sort operations - [**Change Feeds**](./6.feed.md) - Real-time change notifications via the `changes()` method - [**Query**](./7.query.md) - The base class providing execution and async iteration - [**Datum**](./8.datum.md) - A single value with field access, transformation, and lookup capabilities - [**ValueProxy**](./9.valueproxy.md) - Proxy for in-query value operations (arithmetic, string, date, array, object)