IDataEngine — the storage driver contract
Reference for the Data Engine contract — the core data persistence layer for CRUD operations, queries, aggregations, and transactions
The Data Engine is the core persistence layer of ObjectStack. Every data operation — inserts, finds, updates, deletes, counts, and aggregations — flows through this contract. The Kernel delegates to the Data Engine after applying security, validation, and hooks.
Source: packages/spec/src/contracts/data-engine.ts
Schema: packages/spec/src/data/data-engine.zod.ts
Service name: data (registered via CoreServiceName)
Interface Definition
The canonical IDataEngine interface uses QueryAST-aligned parameter names (where, fields, orderBy, limit, offset, expand) — no mechanical translation is needed between the Engine and Driver layers.
import type {
BaseEngineOptions,
EngineQueryOptions,
DataEngineInsertOptions,
EngineUpdateOptions,
EngineDeleteOptions,
EngineAggregateOptions,
EngineCountOptions,
} from '@objectstack/spec/data';
export interface IDataEngine {
// Query (reads take the execution context in a TRAILING options argument —
// the same position the write methods take theirs)
find(objectName: string, query?: EngineQueryOptions, options?: BaseEngineOptions): Promise<any[]>;
findOne(objectName: string, query?: EngineQueryOptions, options?: BaseEngineOptions): Promise<any>;
count(objectName: string, query?: EngineCountOptions, options?: BaseEngineOptions): Promise<number>;
aggregate(objectName: string, query: EngineAggregateOptions, options?: BaseEngineOptions): Promise<any[]>;
// Mutation (write ops also accept in-process WriteObservabilityOptions — see `update`)
insert(objectName: string, data: any | any[], options?: DataEngineInsertOptions & WriteObservabilityOptions): Promise<any>;
update(objectName: string, data: any, options?: EngineUpdateOptions & WriteObservabilityOptions): Promise<any>;
delete(objectName: string, options?: EngineDeleteOptions): Promise<any>;
// AI / Vector Search (optional)
vectorFind?(objectName: string, vector: number[], options?: {
where?: any; limit?: number; fields?: string[]; threshold?: number;
}): Promise<any[]>;
// Raw Command Escape Hatch (optional)
execute?(command: any, options?: Record<string, any>): Promise<any>;
// Driver Registry (optional — engines that own named drivers)
getDefaultDriverName?(): string | undefined;
getDriverByName?(name: string): IDataDriver | undefined;
}Query Operations
All query methods use canonical QueryAST parameter names: where, fields, orderBy, limit, offset, expand.
Reads take the execution context in the trailing options argument, the same
position the write methods take theirs — find, findOne, count and aggregate
all accept options?: BaseEngineOptions.
This matters because the mistake it prevents is silent. The same { context } object
is correct as the third argument to insert, and passing it as the third argument to
find used to be dropped without error — so an intended isSystem bypass simply
vanished, and control-plane reads started coming back empty once org-scoping hooks
landed (#4251).
query.context remains supported. When both are given, options.context wins.
find
Executes a structured query with filtering, sorting, pagination, and field selection. Returns an array of records.
const tasks = await engine.find('task', {
where: {
status: 'open',
priority: { $in: ['high', 'critical'] },
},
orderBy: [{ field: 'due_date', order: 'asc' }],
limit: 20,
offset: 0,
fields: ['id', 'title', 'status', 'priority', 'due_date'],
});EngineQueryOptions
Defined by EngineQueryOptionsSchema in @objectstack/spec:
interface EngineQueryOptions {
where?: FilterCondition; // WHERE clause — MongoDB-style $op
fields?: FieldNode[]; // SELECT — the object's OWN column names; related
// data comes from `expand`, not a dotted path (#7532)
orderBy?: SortNode[]; // ORDER BY
limit?: number; // LIMIT
offset?: number; // OFFSET
top?: number; // Alias for limit (OData compat)
search?: string | FullTextSearch; // Full-text search — the bare query text
// is canonical (ADR-0061 D1); the object
// form carries the Tier-2 knobs (#7178)
searchFields?: string[]; // Fields the `search` expansion may match
// against — a validated override, intersected
// with the object's declared/derived
// searchable set (ADR-0061 D1)
expand?: Record<string, QueryAST>; // Recursive relation loading
context?: ExecutionContext; // Identity, tenant, transaction — any subset
}ExecutionContext is the author state — every field optional (the parse result,
with defaults applied, is ExecutionContextParsed). Supply what you have, the engine reads what it needs.
What it needs is a principal or an explicit elevation. Pass the caller's own
context (a user id, a position or a named permission set), or, for platform code
whose own door already authorized the caller, the system opt-in
{ isSystem: true }. A context that carries neither is refused by the security
plugin with 403 PERMISSION_DENIED (PermissionDeniedError) before the operation
runs, for every verb (ADR-0096 D5). { flowRunId } alone is such a context: a run
id is provenance, not identity, and grants nothing, so a context that carries it
must also carry the caller's principal or isSystem: true.
Removed in protocol 17: cursor and distinct
Both keys were removed from EngineQueryOptions in protocol 17 (#4286,
ADR-0049), alongside the identically-named keys on Query. They are not merely
absent: the schema keeps a tombstone for each, so a query still carrying one is
rejected by name with the migration prose below rather than silently ignored.
cursor?: Record<string, unknown>(keyset pagination) — no driver ever implemented it, so the cursor was accepted and ignored and every page came back identical (a caller looping "untilhasMoreis false" never terminates).QueryBuilder.cursor()was removed with it. Express the keyset as an ordinarywherepredicate on your sort key —where: { created_at: { $gt: last.created_at } }with the matchingorderBy— which every driver executes with canonicalised comparands. A first-class cursor, if ever built, will be a response-minted opaque token, not this caller-built record.distinct?: boolean(SELECT DISTINCT) — no driver ever rendered it, and the flag's only observable effect was MIS-WIRED: the REST list path treated a distinct query as not countable and silently degradedtotal/hasMoreto a page-local estimate while still returning duplicate rows.QueryBuilder.distinct()was removed with it, and the count suppression is gone (totalis truthful again). For unique values of one column use the SQL/memory drivers'distinct(object, field)door; for unique combinations,groupBy; for a deduplicated count, thecount_distinctaggregation.
FilterCondition (where)
Filters use the canonical where + MongoDB-style $op object syntax from FilterConditionSchema:
// Implicit equality
where: { status: 'active' }
// Explicit operators
where: { amount: { $gt: 50000 } }
// Logical combinations
where: {
$and: [
{ status: 'open' },
{ priority: { $in: ['high', 'critical'] } },
],
}
// Logical OR
where: {
$or: [
{ role: 'admin' },
{ email: { $contains: '@company.com' } },
],
}
// Nested relation filter
where: {
account: { industry: 'tech' },
}A nested relation filter is a condition on a related record's own fields, written
beneath a relation field (lookup, master_detail, user or tree, single or
multiple). The engine serves it in where, the same on every driver that serves it (below): it reads the
related object with the condition as the caller — that object's row scope and field
permissions apply, so a condition on a field the caller cannot read is refused
(PERMISSION_DENIED / 403), never answered with an empty list — and then matches the
relation field against what that read selects: on a read verb, a single-valued relation is
one subquery inside the read's own statement where that is provably the same read (the
related read is planned, not run: its read scope and the condition become the subquery's
WHERE, so no id list is read and none is capped — the related object's read restrictions
the planned read observes are carried into the subquery, or the hop falls back to the id
read); otherwise $in on the
ids that read returns, any member on a multi-valued one (multiple: true). No related record matching selects no
rows; under $not, a record whose relation is empty satisfies the negation.
It reaches up to three relationships (ADR-0071's hop limit): every key must be a field
the related object declares, and a relation key may carry a condition of its own
({ account: { owner: { region: 'NA' } } }), each hop read as the caller with its own read
scope; a fourth relationship and the dotted { account: { 'owner.region': 'NA' } } are
refused. Where ids are read (a multi-valued relation, update, delete) a
condition matching more than 1,000 related records is refused with INVALID_FILTER / 400
rather than run over a cut-off list. The id read, with that cap, is also what serves a
single-valued relation on a read verb in each of these cases:
- a related object on another datasource;
- a federated related object;
- a related object whose reads an object-scoped middleware or an
afterFindhook shapes; - a related object read under different driver options than the outer object (its tenant scope, most commonly) — decided before the related read is planned where the registry answers it (the two objects' tenancy class under a walled posture), at the executor boundary otherwise;
- a related read that a middleware answers itself (or adds rows to after the driver call).
A driver that compiles no subquery is not one of those cases. The SQL drivers compile it
and the in-memory driver evaluates it in process; each declares the
DriverCapabilities.readableIdsLeaf bit. On a driver without it (MongoDB, OData), a
single-valued relation condition on a read verb is refused before anything is planned or
read, INVALID_FILTER / 400, naming the driver and the two-step route below. A
multi-valued relation and update / delete keep the capped id read there. An analytics
dimension through a lookup is refused on such a driver the same way, INVALID_QUERY / 400.
A read rule that narrows a related object's rows after its driver call bounds a relation
condition on that object only when it is registered for that object — as an object-keyed
middleware or an afterFind hook; registered that way, the hop keeps the id read.
A hop that falls back after planning (a middleware answering the related read, or driver
options only the request decides) dispatches the related read twice: its middleware chain and beforeFind hooks run for the
planned read and again for the id read. Past the cap, run the two steps yourself — filter
the related object, then match its ids:
const tech = await engine.find('account', { where: { industry: 'tech' }, fields: ['id'] });
where: { account: { $in: tech.map((a) => a.id) } }
// On a multi-valued lookup, one $contains per id:
where: { $or: tech.map((a) => ({ accounts: { $contains: a.id } })) }An aggregation's own filter and having do not serve the nested form (put the
condition in where), and a plain object with no $ operator beneath a json field —
{ meta: { a: 1 } }, a whole-value match — is refused with INVALID_FILTER / 400 on
every driver. A dotted path ({ 'account.industry': 'tech' }) is refused with
INVALID_FIELD / 400: write it nested instead.
Supported operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $between, $contains, $notContains, $startsWith, $endsWith, $null, $exists
Logical operators: $and, $or, $not
findOne
Returns the ONE record the query selects, or null.
const task = await engine.findOne('task', {
where: { title: 'Implement login page' },
fields: ['id', 'title', 'status'],
});The query must say which record it wants — a where (or a search that
expands to one), or an orderBy meaning "the first record in this order". A
query with neither is rejected (#4419):
await engine.findOne('task', {}); // throws
await engine.findOne('task', { // the newest task
orderBy: [{ field: 'created_at', order: 'desc' }],
});
await engine.find('task', { limit: 1 }); // any task will dofindOne reads a single row, so a missing predicate does not come back as
null — it comes back as the object's first row, a real record unrelated to
the request that no if (!task) check can catch. No ordering is imposed when
you supply none: findOne promises a matching record, never a position in a
sequence.
count
Returns the number of records matching a filter without fetching data.
const openTasks = await engine.count('task', {
where: { status: 'open' },
});
// 23Mutation Operations
insert
Creates one or more records. Returns the inserted record(s) with system-generated fields (id, created_at, etc.).
const task = await engine.insert('task', {
title: 'Implement login page',
status: 'open',
priority: 'high',
assigned_to: 'usr_01HQ3V5K8N2M4P6R7T9W',
});
console.log(task.id); // "tsk_01HQ4A7B9D3F5G8J2K4L"
console.log(task.created_at); // "2025-01-20T10:30:00.000Z"Bulk insert:
const tasks = await engine.insert('task', [
{ title: 'Task 1', status: 'open', priority: 'high' },
{ title: 'Task 2', status: 'open', priority: 'medium' },
{ title: 'Task 3', status: 'open', priority: 'low' },
]);DataEngineInsertOptions
interface DataEngineInsertOptions {
returning?: boolean; // Return inserted record(s)? Default: true
context?: ExecutionContext; // Identity, tenant, transaction — any subset
}update
Updates specific fields on matched record(s). The where clause in options identifies target records.
const updated = await engine.update('task',
{ status: 'in_progress', estimated_hours: 12 },
{ where: { id: 'tsk_01HQ4A7B9D3F5G8J2K4L' } }
);Partial Updates: Only fields included in the data parameter are modified. Omitted fields retain their current values.
EngineUpdateOptions
interface EngineUpdateOptions {
where?: FilterCondition; // Filter to identify records (WHERE)
upsert?: boolean; // Insert if not found? Default: false
multi?: boolean; // Update multiple records? Default: false
returning?: boolean; // Return updated record(s)? Default: false
context?: ExecutionContext;
}WriteObservabilityOptions
The write methods (insert / update) additionally accept five in-process
options. Two govern what happens when caller-supplied write fields are legally
stripped from the payload before the driver write: observe the strip
(onFieldsDropped) or refuse the write outright (strictReadonlyWrites). The
third, onValidationAdvisory, reports the write's advisory validation-rule hits.
The fourth, onMentionsWithheld, reports the users a comment write @mentioned who
will not be notified.
The fifth, onNotice, is how a hook tells the person who made the write what
the save set in motion.
The strips these two options cover are the engine's legal ones:
| Strip | reason | Verbs | Writers it skips |
|---|---|---|---|
Static readonly: true (#2948; on insert too since the 2026-09-03 ruling, #14147) | readonly | insert and update | isSystem |
A TRUE readonlyWhen predicate (#3042) | readonly_when | update | none at the API boundary — every caller, isSystem included; a value a beforeUpdate hook derived or overwrote is not a caller write and is never stripped (#9107) |
Implicitly-readonly runtime-owned type (#5503 — RUNTIME_OWNED_FIELD_TYPES, today autonumber) | readonly | insert and update | isSystem, preserveAudit (#3493) |
Primary-key strip of a payload id the update dispatch already ruled is not an identifier (#6437) | primary_key | update | none |
A value for a formula field, which the engine computes on read and no driver has a column for (#20805) | computed | insert and update | none — every context, isSystem included |
A value for a stored field (any type but formula) that declares expression, when it differs from the value the engine computes on every write and stores in its place | stored_expression | insert and update | none — every context, isSystem included |
An audit provenance value (created_by, created_at, updated_by, updated_at) the caller sent on a create, when the audit stamp stores a different value in its place (#32278) | readonly | insert | isSystem, preserveAudit |
The stored_expression row is a replacement, not a removal: the field is written,
with the computed value in place of the caller's. A caller that sends the computed
value, or no value for the field, is neither reported nor refused.
The audit provenance row is a replacement too: the stamp is written in place of the
caller's value, and a caller that sends the stamped value, or none, is neither
reported nor refused.
Of the two AUTHOR-DECLARED strips only readonlyWhen is insert-exempt at this seam
(a conditional lock has no prior record on a create); the static readonly strip runs
on insert too since the 2026-09-03 ruling — see On insert below.
interface WriteObservabilityOptions {
onFieldsDropped?: (event: DroppedFieldsEvent) => void;
onValidationAdvisory?: (event: ValidationAdvisoryEvent) => void;
onMentionsWithheld?: (userIds: readonly string[]) => void;
onNotice?: (message: string) => void;
strictReadonlyWrites?: boolean; // refuse instead of stripping. Default: false
}
interface DroppedFieldsEvent {
object: string; // resolved object name
fields: string[]; // caller-supplied fields whose value was not stored
// why they were dropped — an OPEN vocabulary that grows with the write
// path's legal strips; branch on it exhaustively, never with a binary test
reason: 'readonly' | 'readonly_when' | 'primary_key' | 'computed' | 'stored_expression';
}
interface ValidationAdvisoryEvent {
rule: string; // the advisory validation rule's declared `name`
severity: 'warning' | 'info'; // never `error`: an `error` rule refuses the write instead
field: string; // the rule's first declared field, or `_record`
code: string; // the finding code a refused write reports for the same rule
message: string; // the rule's author-written message, in the caller's locale
}onFieldsDropped — quiet and observable
The engine invokes the listener once per strip pass that dropped at least one
caller-supplied field. The write still succeeds and commits without those
fields; the listener exists so callers that report per-field success (e.g. the
flow engine's update_record step) can surface a warning instead of a silent
success. Branch on reason exhaustively — it is an OPEN vocabulary that grows
with the write path's legal strips, never a binary test.
strictReadonlyWrites — loud instead (#5126)
Default false. When true, a write whose payload WOULD have caller-supplied
fields stripped throws before the driver is touched instead of committing the
remainder. Nothing is written: not the stripped fields, not the fields that would
have survived. The strip passes still run — that is how the engine learns WHICH
fields would go — but their result is discarded.
Its coverage is DERIVED from what onFieldsDropped reports, not an enumeration
frozen at #5126: every strip in the table above is refused, and a new reason
adds a new refusal by construction. Covering only the static arm would leave a
trusted caller — the very caller this option exists for, one that already passes
{ context: { isSystem: true } } and is therefore exempt from the static strip —
still losing readonlyWhen fields in silence. The flag's NAME is narrower than
its coverage and stays that way on purpose; the coverage sentence, not the name,
is the contract.
The refusal is ReadonlyFieldRejectedError, code ERR_READONLY_FIELD_REJECTED
(registered in ERROR_CODE_LEDGER under @objectstack/objectql), carrying the
FULL list of rejected fields accumulated across every strip pass the operation
runs — one error naming everything, so a caller fixes its payload once instead of
one round-trip per field. Catch it by code, not instanceof, and read drops
for the per-reason breakdown; the code is stable across reasons deliberately, so
adding a reason never adds an error code.
onFieldsDropped does not fire on a write this option refuses. The two are
alternative outputs of one seam, not a sequence: DroppedFieldsEvent means
"fields dropped and the write completed without them", and under strict the write
does not complete. Quiet-and-observable or loud — pick one per call.
On insert. Until the maintainer ruling of 2026-09-03 (option C, #14147) this
paragraph said the two AUTHOR-DECLARED strips were insert-exempt at this seam
(#3413: an in-process create may seed a readonly: true field's initial value).
That row is superseded: engine.insert now runs the static readonly strip for a
non-system caller — the same stripReadonlyFields, under the same isSystem gate,
as engine.update — and the DataProtocol ingress copy that used to cover external
callers only is deleted. One semantics, one enforcement point. readonlyWhen alone
stays insert-exempt (a conditional lock has no prior record on a create). So an
insert refusal is about a runtime-owned value — a caller-supplied record number —
or a static readonly value from a non-system caller. With the option true
that insert throws (operation: 'insert', every taken field in one list) and
nothing is written; without it the values are stripped, the write completes, a
stripped readonly field falls back to its defaultValue, and onFieldsDropped
fires once with reason: 'readonly'. The writers exempt — and therefore never
refused — differ per strip, and that difference is the 2026-08-08 ruling, not this
one: isSystem exempts both; the preserveAudit historical import reinstating
legacy record numbers (#3493) exempts the runtime-owned strip only, and a
non-system create that asks for it still has its static readonly fields stripped,
with a warn saying the exemption is UPDATE-only (#6640).
onValidationAdvisory — the write's advisory rule hits
The engine calls the listener once per ADVISORY validation-rule hit on the write
the options were passed to: a severity: 'warning' or 'info' rule whose verdict
on the written record was "violated". Advisory rules never block, so the write
proceeds. It is called per row on insert, and on update both by id and per
matched row of a multi update. A nested write that a hook or a flow makes
inside this one carries its own options, so that write's hits never reach this
listener. A rule that could not be evaluated is not a hit, and is reported in the
server log only. The listener fires when the rules are evaluated, before the
driver write, so a hit is provisional until the write resolves. Passing it
changes no server-side reporting: the per-write warn line, and a seed / boot
load's one summary line per rule.
The DataProtocol's createData, updateData and cloneData pass this listener
and answer the hits as warnings (ValidateDataIssue entries carrying rule
and severity), present only when there is at least one hit.
onMentionsWithheld — who a comment's @mentions will not reach
A sys_comment write notifies each user it @mentions, but only a user who can
read the comment and its record: the mention recipient gate withholds the rest.
This listener is told the ids of the users the gate withheld on the write the
options were passed to, whatever its reason: ids only, never the reason. The engine never calls it.
It reaches the mention writer the way every member of this bag reaches an
after* hook, on ctx.input.options, and the writer calls it once per written
comment that withheld anyone. On an update, only a mention the update added is
judged; a mention the comment already carried was judged when it was written. A
nested write that a hook or a flow makes inside this one carries its own options,
so its verdicts never reach this listener.
A reply (a comment with a parent_id) also notifies the thread's starter and the
people who replied in it before, through the same gate (topic collab.reply).
Those are people the author did not name, so the participants the gate withholds
are never reported here: the listener names only users the comment @mentioned.
The DataProtocol's createData and updateData pass this listener and answer the
ids as withheldMentions, on the requester's own answer to that request only and present only when at
least one user was withheld. Nothing is stored on the comment: a stored member
would tell every reader of the comment who cannot read its thread.
onNotice — what the save set in motion
A hook that starts something the person saving should hear about ("Sent to your
manager for approval") calls this listener with one author-written message. It is
info severity: it reports an outcome, never a problem, so it is not a validation
finding and never rides onValidationAdvisory. The engine never calls it. A hook
reaches it the way every member of this bag reaches a hook, on
ctx.input.options: a before* handler reads the caller's bag as passed, an
after* handler after buildDriverOptions widened it.
import type { HookContext } from '@objectstack/spec/data';
import type { WriteObservabilityOptions } from '@objectstack/spec/contracts';
export async function announceApproval(ctx: HookContext): Promise<void> {
const opts = ctx.input.options as WriteObservabilityOptions | undefined;
opts?.onNotice?.('Sent to your manager for approval');
}The listener is often absent (a seed, a flow node, a batch or an import passes
none), so call it optionally. One message per write: a later call replaces an
earlier one, and a message that is not a non-empty string sets nothing. A write
that is refused answers its error, never a notice. A nested write that a hook or a
flow makes inside this one carries its own options, so its notice never reaches
this listener. The sandboxed body face (including a handler the build lowers
into a body) does not carry it: its ctx.input.options is the frozen
{ multi, where } projection.
The DataProtocol's createData and updateData pass this listener and answer
the message as notice, on the requester's own answer to that request only and
present only when a hook set one. Nothing is stored on the record.
Layering — this is the engine seam, and since the 2026-09-03 ruling the only
one. The DataProtocol create faces (createData, cloneData, createManyData,
insertManyData, batchData) forward the caller's payload whole and surface this
seam's onFieldsDropped as their response droppedFields wherever their contract
declares one; none carries a readonly policy of its own any more — see
FieldSchema.readonly.
WriteObservabilityOptions is a TS-contract-level, in-process-only bag —
all five members. It is deliberately not part of the serializable Zod options schemas:
a function is unrepresentable in JSON Schema and cannot be serialized, so remote
callers (REST, the client SDK) never receive these events; and putting
strictReadonlyWrites in the serializable bag would let any client toggle
write-refusal on a security-adjacent path (#5126 ruling). A remote caller can set
none of the three, and for the strips it gets NEITHER behaviour: its write is
stripped and committed, silently from its side — a 200 whose read-only columns
kept their stored values. Widening strict to the wire is a SEPARATE decision.
Advisory rule hits do reach a remote caller, through the answer rather than the
listener: the DataProtocol's createData, updateData and cloneData pass
onValidationAdvisory in-process and answer the hits as warnings, which is how
a remote caller sees them. A listener that throws never breaks the write — the
engine catches and logs.
delete
Deletes record(s) matching the where condition.
await engine.delete('task', {
where: { id: 'tsk_01HQ4A7B9D3F5G8J2K4L' },
});EngineDeleteOptions
interface EngineDeleteOptions {
where?: FilterCondition; // Filter to identify records (WHERE)
multi?: boolean; // Delete multiple records? Default: false
context?: ExecutionContext;
}Aggregation
aggregate
Runs aggregation queries with grouping for analytics and reporting.
const result = await engine.aggregate('task', {
where: { project: 'prj_01HQ3V5K8N' },
groupBy: ['status'],
aggregations: [
{ function: 'count', alias: 'task_count' },
{ function: 'sum', field: 'estimated_hours', alias: 'total_hours' },
{ function: 'avg', field: 'estimated_hours', alias: 'avg_hours' },
],
});
// result:
// [
// { status: 'open', task_count: 15, total_hours: 120, avg_hours: 8 },
// { status: 'in_progress', task_count: 8, total_hours: 96, avg_hours: 12 },
// { status: 'done', task_count: 24, total_hours: 192, avg_hours: 8 },
// ]EngineAggregateOptions
The option keys are listed in the generated
EngineAggregateOptions reference.
aggregations takes AggregationNode entries:
interface AggregationNode {
function: 'count' | 'sum' | 'avg' | 'min' | 'max' | 'count_distinct';
field?: string; // Field to aggregate (optional for COUNT(*))
alias: string; // Result column alias
filter?: FilterCondition; // Per-aggregation FILTER WHERE
}distinct?: boolean was removed from AggregationNode in protocol 17 (#6815,
ADR-0049). Only the engine's in-memory fallback ever honoured it — every SQL face
ignored it — so the same query answered a deduplicated sum or an ordinary one
depending on which backend served it. For a deduplicated count use the
count_distinct function, which every face computes.
Optional Capabilities
vectorFind (AI/RAG)
Perform similarity search using vector embeddings:
const results = await engine.vectorFind?.('document', embeddingVector, {
where: { category: 'technical' },
fields: ['title', 'content'],
limit: 5,
threshold: 0.8,
});Several writes, atomically
There is no batch member: it was never implemented by any engine and was retired
(ADR-0119 D3). In process, wrap the writes in IObjectQLEngine.transaction(cb);
for a batch over one object use the metadata protocol's batchData with
options.atomic: true; over the wire, POST {basePath}/batch.
execute (Raw Command)
Escape hatch for raw driver-specific commands:
const result = await engine.execute?.(
'SELECT * FROM tasks WHERE status = $1',
{ params: ['open'] }
);getDefaultDriverName / getDriverByName (Driver Registry)
Look up the engine's registered drivers. Only engines that own a named-driver
registry implement these (ObjectQL does; test fakes and remote/virtual engines
need not) — always probe with ?.:
const driverName = engine.getDefaultDriverName?.();
const driver = driverName ? engine.getDriverByName?.(driverName) : undefined;This is the surface the runtime uses to re-register the default driver as a
driver.<name> kernel service, which is where os migrate and serve's storage
detection locate drivers.
Error Codes
| Code | HTTP | Description |
|---|---|---|
RECORD_NOT_FOUND | 404 | No record exists with the given ID |
VALIDATION_FAILED | 400 | Data does not match the object schema |
DELETE_RESTRICTED | 409 | Cannot delete; dependent child records reference it via a restrict delete behavior |
Legacy Compatibility
Deprecated Parameter Names
The following legacy parameter names are accepted on the wire (the protocol normalizer) for backward compatibility but should not be used in new code. The protocol normalizer resolves conflicts with canonical names taking precedence.
| Legacy (Deprecated) | Canonical | Notes |
|---|---|---|
filter | where | FilterCondition object |
select | fields | Array of FieldNode (field-name strings) |
sort | orderBy | Array of { field, order } |
skip | offset | Number |
populate | expand | Record of field → QueryAST |
The deprecated DataEngineQueryOptionsSchema, DataEngineUpdateOptionsSchema, DataEngineDeleteOptionsSchema, and DataEngineAggregateOptionsSchema are maintained in @objectstack/spec for backward compatibility but will be removed in a future major version. Migrate to the QueryAST-aligned equivalents: EngineQueryOptionsSchema, EngineUpdateOptionsSchema, EngineDeleteOptionsSchema, EngineAggregateOptionsSchema.