---
title: Data Engine
description: Data Engine protocol schemas
---

{/* ⚠️  AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs go in content/docs/guides/. */}

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.

<Callout type="info">
**Source:** `packages/spec/src/data/data-engine.zod.ts`
</Callout>

## TypeScript Usage

```typescript
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);
```

---

## BaseEngineOptions

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **context** | `Object` | optional |  |


---

## DataEngineAggregateOptions

Options for DataEngine.aggregate operations

### Properties

| 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 |  |


---

## DataEngineAggregateRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **query** | `Object` | ✅ |  |


---

## DataEngineBatchRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **requests** | `Object \| Object \| Object \| Object \| Object \| Object \| Object \| Object \| Object[]` | ✅ |  |
| **transaction** | `boolean` | optional |  |


---

## DataEngineCountOptions

Options for DataEngine.count operations

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **context** | `Object` | optional |  |
| **filter** | `Record<string, any> \| [__schema0](./__schema0)` | optional | Data Engine query filter conditions |


---

## DataEngineCountRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **query** | `Object` | optional |  |


---

## DataEngineDeleteOptions

Options for DataEngine.delete operations

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **context** | `Object` | optional |  |
| **filter** | `Record<string, any> \| [__schema0](./__schema0)` | optional | Data Engine query filter conditions |
| **multi** | `boolean` | optional |  |


---

## DataEngineDeleteRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **id** | `string \| number` | optional | ID for single delete, or use where in options |
| **options** | `Object` | optional |  |


---

## DataEngineExecuteRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **command** | `any` | ✅ |  |
| **options** | `Record<string, any>` | optional |  |


---

## DataEngineFilter

Data Engine query filter conditions

### Union Options

This schema accepts one of the following structures:

#### Option 1

Type: `Record<string, any>`

---

#### Option 2

Reference: [__schema0](./__schema0)

---


---

## DataEngineFindOneRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **query** | `Object` | optional |  |


---

## DataEngineFindRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **query** | `Object` | optional |  |


---

## DataEngineInsertOptions

Options for DataEngine.insert operations

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **context** | `Object` | optional |  |
| **returning** | `boolean` | optional |  |


---

## DataEngineInsertRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **data** | `Record<string, any> \| Record<string, any>[]` | ✅ |  |
| **options** | `Object` | optional | Options for DataEngine.insert operations |


---

## DataEngineQueryOptions

Query options for IDataEngine.find() operations

### Properties

| 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 |  |


---

## DataEngineRequest

Virtual ObjectQL Request Protocol

### Union Options

This schema accepts one of the following structures:

#### Option 1

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **query** | `Object` | optional |  |

---

#### Option 2

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **query** | `Object` | optional |  |

---

#### Option 3

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **data** | `Record<string, any> \| Record<string, any>[]` | ✅ |  |
| **options** | `Object` | optional | Options for DataEngine.insert operations |

---

#### Option 4

### Properties

| 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 |  |

---

#### Option 5

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **id** | `string \| number` | optional | ID for single delete, or use where in options |
| **options** | `Object` | optional |  |

---

#### Option 6

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **query** | `Object` | optional |  |

---

#### Option 7

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **object** | `string` | ✅ |  |
| **query** | `Object` | ✅ |  |

---

#### Option 8

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **requests** | `Object \| Object \| Object \| Object \| Object \| Object \| Object \| Object \| Object[]` | ✅ |  |
| **transaction** | `boolean` | optional |  |

---

#### Option 9

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **method** | `string` | ✅ |  |
| **command** | `any` | ✅ |  |
| **options** | `Record<string, any>` | optional |  |

---

#### Option 10

### Properties

| 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 |  |

---


---

## DataEngineSort

Sort order definition

### Union Options

This schema accepts one of the following structures:

#### Option 1

Type: `Record<string, Enum<'asc' | 'desc'>>`

---

#### Option 2

Type: `Record<string, number | number>`

---

#### Option 3

Type: `Object[]`

---


---

## DataEngineUpdateOptions

Options for DataEngine.update operations

### Properties

| 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 |  |


---

## DataEngineUpdateRequest

### Properties

| 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 |  |


---

## DataEngineVectorFindRequest

### Properties

| 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 |  |


---

## EngineAggregateOptions

QueryAST-aligned options for DataEngine.aggregate operations

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **context** | `Object` | optional |  |
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional |  |
| **groupBy** | `string[]` | optional |  |
| **aggregations** | `Object[]` | optional |  |


---

## EngineCountOptions

QueryAST-aligned options for DataEngine.count operations

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **context** | `Object` | optional |  |
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional |  |


---

## EngineDeleteOptions

QueryAST-aligned options for DataEngine.delete operations

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **context** | `Object` | optional |  |
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional |  |
| **multi** | `boolean` | optional |  |


---

## EngineQueryOptions

QueryAST-aligned query options for IDataEngine.find() operations

### Properties

| 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 |  |


---

## EngineUpdateOptions

QueryAST-aligned options for DataEngine.update operations

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **context** | `Object` | optional |  |
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional |  |
| **upsert** | `boolean` | optional |  |
| **multi** | `boolean` | optional |  |
| **returning** | `boolean` | optional |  |


---

