|
| 1 | +--- |
| 2 | +title: Data Engine |
| 3 | +description: Data Engine protocol schemas |
| 4 | +--- |
| 5 | + |
| 6 | +# Data Engine |
| 7 | + |
| 8 | +<Callout type="info"> |
| 9 | +**Source:** `packages/spec/src/data/data-engine.zod.ts` |
| 10 | +</Callout> |
| 11 | + |
| 12 | +## TypeScript Usage |
| 13 | + |
| 14 | +```typescript |
| 15 | +import { DataEngineAggregateOptionsSchema, DataEngineAggregateRequestSchema, DataEngineBatchRequestSchema, DataEngineContractSchema, DataEngineCountOptionsSchema, DataEngineCountRequestSchema, DataEngineDeleteOptionsSchema, DataEngineDeleteRequestSchema, DataEngineExecuteRequestSchema, DataEngineFilterSchema, DataEngineFindOneRequestSchema, DataEngineFindRequestSchema, DataEngineInsertOptionsSchema, DataEngineInsertRequestSchema, DataEngineQueryOptionsSchema, DataEngineRequestSchema, DataEngineSortSchema, DataEngineUpdateOptionsSchema, DataEngineUpdateRequestSchema, DataEngineVectorFindRequestSchema } from '@objectstack/spec/data'; |
| 16 | +import type { DataEngineAggregateOptions, DataEngineAggregateRequest, DataEngineBatchRequest, DataEngineContract, DataEngineCountOptions, DataEngineCountRequest, DataEngineDeleteOptions, DataEngineDeleteRequest, DataEngineExecuteRequest, DataEngineFilter, DataEngineFindOneRequest, DataEngineFindRequest, DataEngineInsertOptions, DataEngineInsertRequest, DataEngineQueryOptions, DataEngineRequest, DataEngineSort, DataEngineUpdateOptions, DataEngineUpdateRequest, DataEngineVectorFindRequest } from '@objectstack/spec/data'; |
| 17 | + |
| 18 | +// Validate data |
| 19 | +const result = DataEngineAggregateOptionsSchema.parse(data); |
| 20 | +``` |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## DataEngineAggregateOptions |
| 25 | + |
| 26 | +Options for DataEngine.aggregate operations |
| 27 | + |
| 28 | +### Properties |
| 29 | + |
| 30 | +| Property | Type | Required | Description | |
| 31 | +| :--- | :--- | :--- | :--- | |
| 32 | +| **filter** | `Record<string, any> \| any` | optional | Data Engine query filter conditions | |
| 33 | +| **groupBy** | `string[]` | optional | | |
| 34 | +| **aggregations** | `object[]` | optional | | |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## DataEngineAggregateRequest |
| 39 | + |
| 40 | +### Properties |
| 41 | + |
| 42 | +| Property | Type | Required | Description | |
| 43 | +| :--- | :--- | :--- | :--- | |
| 44 | +| **method** | `string` | ✅ | | |
| 45 | +| **object** | `string` | ✅ | | |
| 46 | +| **query** | `object` | ✅ | Options for DataEngine.aggregate operations | |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## DataEngineBatchRequest |
| 51 | + |
| 52 | +### Properties |
| 53 | + |
| 54 | +| Property | Type | Required | Description | |
| 55 | +| :--- | :--- | :--- | :--- | |
| 56 | +| **method** | `string` | ✅ | | |
| 57 | +| **requests** | `object \| object \| object \| object \| object \| object \| object \| object \| object[]` | ✅ | | |
| 58 | +| **transaction** | `boolean` | optional | | |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +## DataEngineContract |
| 63 | + |
| 64 | +Standard Data Engine Contract |
| 65 | + |
| 66 | +### Properties |
| 67 | + |
| 68 | +| Property | Type | Required | Description | |
| 69 | +| :--- | :--- | :--- | :--- | |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## DataEngineCountOptions |
| 74 | + |
| 75 | +Options for DataEngine.count operations |
| 76 | + |
| 77 | +### Properties |
| 78 | + |
| 79 | +| Property | Type | Required | Description | |
| 80 | +| :--- | :--- | :--- | :--- | |
| 81 | +| **filter** | `Record<string, any> \| any` | optional | Data Engine query filter conditions | |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +## DataEngineCountRequest |
| 86 | + |
| 87 | +### Properties |
| 88 | + |
| 89 | +| Property | Type | Required | Description | |
| 90 | +| :--- | :--- | :--- | :--- | |
| 91 | +| **method** | `string` | ✅ | | |
| 92 | +| **object** | `string` | ✅ | | |
| 93 | +| **query** | `object` | optional | Options for DataEngine.count operations | |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## DataEngineDeleteOptions |
| 98 | + |
| 99 | +Options for DataEngine.delete operations |
| 100 | + |
| 101 | +### Properties |
| 102 | + |
| 103 | +| Property | Type | Required | Description | |
| 104 | +| :--- | :--- | :--- | :--- | |
| 105 | +| **filter** | `Record<string, any> \| any` | optional | Data Engine query filter conditions | |
| 106 | +| **multi** | `boolean` | optional | | |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## DataEngineDeleteRequest |
| 111 | + |
| 112 | +### Properties |
| 113 | + |
| 114 | +| Property | Type | Required | Description | |
| 115 | +| :--- | :--- | :--- | :--- | |
| 116 | +| **method** | `string` | ✅ | | |
| 117 | +| **object** | `string` | ✅ | | |
| 118 | +| **id** | `any` | optional | ID for single delete, or use filter in options | |
| 119 | +| **options** | `object` | optional | Options for DataEngine.delete operations | |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## DataEngineExecuteRequest |
| 124 | + |
| 125 | +### Properties |
| 126 | + |
| 127 | +| Property | Type | Required | Description | |
| 128 | +| :--- | :--- | :--- | :--- | |
| 129 | +| **method** | `string` | ✅ | | |
| 130 | +| **command** | `any` | optional | | |
| 131 | +| **options** | `Record<string, any>` | optional | | |
| 132 | + |
| 133 | +--- |
| 134 | + |
| 135 | +## DataEngineFilter |
| 136 | + |
| 137 | +Data Engine query filter conditions |
| 138 | + |
| 139 | +--- |
| 140 | + |
| 141 | +## DataEngineFindOneRequest |
| 142 | + |
| 143 | +### Properties |
| 144 | + |
| 145 | +| Property | Type | Required | Description | |
| 146 | +| :--- | :--- | :--- | :--- | |
| 147 | +| **method** | `string` | ✅ | | |
| 148 | +| **object** | `string` | ✅ | | |
| 149 | +| **query** | `object` | optional | Query options for IDataEngine.find() operations | |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +## DataEngineFindRequest |
| 154 | + |
| 155 | +### Properties |
| 156 | + |
| 157 | +| Property | Type | Required | Description | |
| 158 | +| :--- | :--- | :--- | :--- | |
| 159 | +| **method** | `string` | ✅ | | |
| 160 | +| **object** | `string` | ✅ | | |
| 161 | +| **query** | `object` | optional | Query options for IDataEngine.find() operations | |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +## DataEngineInsertOptions |
| 166 | + |
| 167 | +Options for DataEngine.insert operations |
| 168 | + |
| 169 | +### Properties |
| 170 | + |
| 171 | +| Property | Type | Required | Description | |
| 172 | +| :--- | :--- | :--- | :--- | |
| 173 | +| **returning** | `boolean` | optional | | |
| 174 | + |
| 175 | +--- |
| 176 | + |
| 177 | +## DataEngineInsertRequest |
| 178 | + |
| 179 | +### Properties |
| 180 | + |
| 181 | +| Property | Type | Required | Description | |
| 182 | +| :--- | :--- | :--- | :--- | |
| 183 | +| **method** | `string` | ✅ | | |
| 184 | +| **object** | `string` | ✅ | | |
| 185 | +| **data** | `Record<string, any> \| Record<string, any>[]` | ✅ | | |
| 186 | +| **options** | `object` | optional | Options for DataEngine.insert operations | |
| 187 | + |
| 188 | +--- |
| 189 | + |
| 190 | +## DataEngineQueryOptions |
| 191 | + |
| 192 | +Query options for IDataEngine.find() operations |
| 193 | + |
| 194 | +### Properties |
| 195 | + |
| 196 | +| Property | Type | Required | Description | |
| 197 | +| :--- | :--- | :--- | :--- | |
| 198 | +| **filter** | `Record<string, any> \| any` | optional | Data Engine query filter conditions | |
| 199 | +| **select** | `string[]` | optional | | |
| 200 | +| **sort** | `Record<string, Enum<'asc' \| 'desc'>> \| Record<string, Enum<'1' \| '-1'>> \| object[]` | optional | Sort order definition | |
| 201 | +| **limit** | `integer` | optional | | |
| 202 | +| **skip** | `integer` | optional | | |
| 203 | +| **top** | `integer` | optional | | |
| 204 | +| **populate** | `string[]` | optional | | |
| 205 | + |
| 206 | +--- |
| 207 | + |
| 208 | +## DataEngineRequest |
| 209 | + |
| 210 | +Virtual ObjectQL Request Protocol |
| 211 | + |
| 212 | +--- |
| 213 | + |
| 214 | +## DataEngineSort |
| 215 | + |
| 216 | +Sort order definition |
| 217 | + |
| 218 | +--- |
| 219 | + |
| 220 | +## DataEngineUpdateOptions |
| 221 | + |
| 222 | +Options for DataEngine.update operations |
| 223 | + |
| 224 | +### Properties |
| 225 | + |
| 226 | +| Property | Type | Required | Description | |
| 227 | +| :--- | :--- | :--- | :--- | |
| 228 | +| **filter** | `Record<string, any> \| any` | optional | Data Engine query filter conditions | |
| 229 | +| **upsert** | `boolean` | optional | | |
| 230 | +| **multi** | `boolean` | optional | | |
| 231 | +| **returning** | `boolean` | optional | | |
| 232 | + |
| 233 | +--- |
| 234 | + |
| 235 | +## DataEngineUpdateRequest |
| 236 | + |
| 237 | +### Properties |
| 238 | + |
| 239 | +| Property | Type | Required | Description | |
| 240 | +| :--- | :--- | :--- | :--- | |
| 241 | +| **method** | `string` | ✅ | | |
| 242 | +| **object** | `string` | ✅ | | |
| 243 | +| **data** | `Record<string, any>` | ✅ | | |
| 244 | +| **id** | `any` | optional | ID for single update, or use filter in options | |
| 245 | +| **options** | `object` | optional | Options for DataEngine.update operations | |
| 246 | + |
| 247 | +--- |
| 248 | + |
| 249 | +## DataEngineVectorFindRequest |
| 250 | + |
| 251 | +### Properties |
| 252 | + |
| 253 | +| Property | Type | Required | Description | |
| 254 | +| :--- | :--- | :--- | :--- | |
| 255 | +| **method** | `string` | ✅ | | |
| 256 | +| **object** | `string` | ✅ | | |
| 257 | +| **vector** | `number[]` | ✅ | | |
| 258 | +| **filter** | `Record<string, any> \| any` | optional | Data Engine query filter conditions | |
| 259 | +| **select** | `string[]` | optional | | |
| 260 | +| **limit** | `integer` | optional | | |
| 261 | +| **threshold** | `number` | optional | | |
| 262 | + |
0 commit comments