Data Engine
Data Engine protocol schemas
Data Engine Protocol
Defines the standard interface for data persistence engines in ObjectStack.
This protocol abstracts the underlying storage mechanism (SQL, NoSQL, API, Memory),
allowing the ObjectQL engine to execute standardized CRUD and Aggregation operations
regardless of where the data resides.
The Data Engine acts as the "Driver" layer in the Hexagonal Architecture.
Source: packages/spec/src/data/data-engine.zod.ts
import { BaseEngineOptions, DataEngineAggregateOptions, DataEngineAggregateRequest, DataEngineBatchRequest, DataEngineCountOptions, DataEngineCountRequest, DataEngineDeleteOptions, DataEngineDeleteRequest, DataEngineExecuteRequest, DataEngineFilter, DataEngineFindOneRequest, DataEngineFindRequest, DataEngineInsertOptions, DataEngineInsertRequest, DataEngineQueryOptions, DataEngineRequest, DataEngineSort, DataEngineUpdateOptions, DataEngineUpdateRequest, DataEngineVectorFindRequest, EngineAggregateOptions, EngineCountOptions, EngineDeleteOptions, EngineQueryOptions, EngineUpdateOptions } from '@objectstack/spec/data';
import type { BaseEngineOptions, DataEngineAggregateOptions, DataEngineAggregateRequest, DataEngineBatchRequest, DataEngineCountOptions, DataEngineCountRequest, DataEngineDeleteOptions, DataEngineDeleteRequest, DataEngineExecuteRequest, DataEngineFilter, DataEngineFindOneRequest, DataEngineFindRequest, DataEngineInsertOptions, DataEngineInsertRequest, DataEngineQueryOptions, DataEngineRequest, DataEngineSort, DataEngineUpdateOptions, DataEngineUpdateRequest, DataEngineVectorFindRequest, EngineAggregateOptions, EngineCountOptions, EngineDeleteOptions, EngineQueryOptions, EngineUpdateOptions } from '@objectstack/spec/data';
// Validate data
const result = BaseEngineOptions.parse(data);
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
Options for DataEngine.aggregate operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| filter | Record<string, any> | [__schema0](./__schema0) | optional | Data Engine query filter conditions |
| groupBy | string[] | optional | |
| aggregations | Object[] | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| query | Object | ✅ | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| requests | Object | Object | Object | Object | Object | Object | Object | Object | Object[] | ✅ | |
| transaction | boolean | optional | |
Options for DataEngine.count operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| filter | Record<string, any> | [__schema0](./__schema0) | optional | Data Engine query filter conditions |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| query | Object | optional | |
Options for DataEngine.delete operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| filter | Record<string, any> | [__schema0](./__schema0) | optional | Data Engine query filter conditions |
| multi | boolean | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| id | string | number | optional | ID for single delete, or use where in options |
| options | Object | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| command | any | ✅ | |
| options | Record<string, any> | optional | |
Data Engine query filter conditions
This schema accepts one of the following structures:
Type: Record<string, any>
Reference: __schema0
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| query | Object | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| query | Object | optional | |
Options for DataEngine.insert operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| returning | boolean | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| data | Record<string, any> | Record<string, any>[] | ✅ | |
| options | Object | optional | Options for DataEngine.insert operations |
Query options for IDataEngine.find() operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| filter | Record<string, any> | [__schema0](./__schema0) | optional | Data Engine query filter conditions |
| select | string[] | optional | |
| sort | Record<string, Enum<'asc' | 'desc'>> | Record<string, number | number> | Object[] | optional | Sort order definition |
| limit | integer | optional | |
| skip | integer | optional | |
| top | integer | optional | |
| populate | string[] | optional | |
Virtual ObjectQL Request Protocol
This schema accepts one of the following structures:
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| query | Object | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| query | Object | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| data | Record<string, any> | Record<string, any>[] | ✅ | |
| options | Object | optional | Options for DataEngine.insert operations |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| data | Record<string, any> | ✅ | |
| id | string | number | optional | ID for single update, or use where in options |
| options | Object | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| id | string | number | optional | ID for single delete, or use where in options |
| options | Object | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| query | Object | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| query | Object | ✅ | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| requests | Object | Object | Object | Object | Object | Object | Object | Object | Object[] | ✅ | |
| transaction | boolean | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| command | any | ✅ | |
| options | Record<string, any> | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| vector | number[] | ✅ | |
| where | Record<string, any> | [__schema0](./__schema0) | optional | |
| fields | string[] | optional | |
| limit | integer | optional | |
| threshold | number | optional | |
Sort order definition
This schema accepts one of the following structures:
Type: Record<string, Enum<'asc' | 'desc'>>
Type: Record<string, number | number>
Type: Object[]
Options for DataEngine.update operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| filter | Record<string, any> | [__schema0](./__schema0) | optional | Data Engine query filter conditions |
| upsert | boolean | optional | |
| multi | boolean | optional | |
| returning | boolean | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| data | Record<string, any> | ✅ | |
| id | string | number | optional | ID for single update, or use where in options |
| options | Object | optional | |
| Property | Type | Required | Description |
|---|
| method | string | ✅ | |
| object | string | ✅ | |
| vector | number[] | ✅ | |
| where | Record<string, any> | [__schema0](./__schema0) | optional | |
| fields | string[] | optional | |
| limit | integer | optional | |
| threshold | number | optional | |
QueryAST-aligned options for DataEngine.aggregate operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| where | Record<string, any> | [__schema0](./__schema0) | optional | |
| groupBy | string[] | optional | |
| aggregations | Object[] | optional | |
QueryAST-aligned options for DataEngine.count operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| where | Record<string, any> | [__schema0](./__schema0) | optional | |
QueryAST-aligned options for DataEngine.delete operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| where | Record<string, any> | [__schema0](./__schema0) | optional | |
| multi | boolean | optional | |
QueryAST-aligned query options for IDataEngine.find() operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| where | Record<string, any> | [__schema0](./__schema0) | optional | |
| fields | [__schema1](./__schema1)[] | optional | |
| orderBy | Object[] | optional | |
| limit | number | optional | |
| offset | number | optional | |
| top | number | optional | |
| cursor | Record<string, any> | optional | |
| search | Object | optional | |
| expand | Record<string, [__schema2](./__schema2)> | optional | |
| distinct | boolean | optional | |
QueryAST-aligned options for DataEngine.update operations
| Property | Type | Required | Description |
|---|
| context | Object | optional | |
| where | Record<string, any> | [__schema0](./__schema0) | optional | |
| upsert | boolean | optional | |
| multi | boolean | optional | |
| returning | boolean | optional | |