Database
Results
AQL operations return structured result values that communicate what happened during execution. This section covers the result types produced by write operations and change feeds.
Result Types
- 2. Insert Results - Return values from insert operations
- 3. Index Definitions - Index configuration in schema definitions
- 4. Table Definitions - Table structure and field types
- 5. Schema and Instance Management - Schema lifecycle and instance management
- 6. Change Events - Structure of change feed notifications
Common Patterns
All AQL operations follow a consistent pattern:
- Build a query by chaining operations.
- Execute the query with
run()orawaitto get the result. - Process the structured result.
import { Schema } from "@antelopejs/interface-database";
const schema = Schema.get("myapp")!;
const users = schema.instance().table("users");
// Insert returns an array of generated IDs
const ids = await users.insert({ name: "Alice", email: "[email protected]" });
console.log("New ID:", ids[0]);
// Update/delete return the number of affected documents
const count = await users.get("user-123").update({ status: "active" });
console.log(`Modified ${count} documents`);
// Delete returns the number of deleted documents
const deleted = await users.get("user-123").delete();
console.log(`Deleted ${deleted} documents`);
Lookup
The lookup method performs a foreign key join, replacing a field in your documents with the referenced data from another table. It is available on both Stream<T> and Datum<T>.
Insert Results
The insert method on Table<T> returns a Query<string[]> that resolves to an array of the generated or provided primary keys for the inserted documents.