|
| 1 | +--- |
| 2 | +title: Driver Nosql |
| 3 | +description: Driver Nosql protocol schemas |
| 4 | +--- |
| 5 | + |
| 6 | +# Driver Nosql |
| 7 | + |
| 8 | +<Callout type="info"> |
| 9 | +**Source:** `packages/spec/src/system/driver-nosql.zod.ts` |
| 10 | +</Callout> |
| 11 | + |
| 12 | +## TypeScript Usage |
| 13 | + |
| 14 | +```typescript |
| 15 | +import { AggregationPipelineSchema, AggregationStageSchema, ConsistencyLevelSchema, DocumentValidationSchemaSchema, NoSQLDataTypeMappingSchema, NoSQLDatabaseTypeSchema, NoSQLDriverConfigSchema, NoSQLIndexSchema, NoSQLIndexTypeSchema, NoSQLOperationTypeSchema, NoSQLQueryOptionsSchema, NoSQLTransactionOptionsSchema, ReplicationConfigSchema, ShardingConfigSchema } from '@objectstack/spec/system'; |
| 16 | +import type { AggregationPipeline, AggregationStage, ConsistencyLevel, DocumentValidationSchema, NoSQLDataTypeMapping, NoSQLDatabaseType, NoSQLDriverConfig, NoSQLIndex, NoSQLIndexType, NoSQLOperationType, NoSQLQueryOptions, NoSQLTransactionOptions, ReplicationConfig, ShardingConfig } from '@objectstack/spec/system'; |
| 17 | + |
| 18 | +// Validate data |
| 19 | +const result = AggregationPipelineSchema.parse(data); |
| 20 | +``` |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## AggregationPipeline |
| 25 | + |
| 26 | +### Properties |
| 27 | + |
| 28 | +| Property | Type | Required | Description | |
| 29 | +| :--- | :--- | :--- | :--- | |
| 30 | +| **collection** | `string` | ✅ | Collection/table name | |
| 31 | +| **stages** | `object[]` | ✅ | Aggregation pipeline stages | |
| 32 | +| **options** | `object` | optional | Query options | |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## AggregationStage |
| 37 | + |
| 38 | +### Properties |
| 39 | + |
| 40 | +| Property | Type | Required | Description | |
| 41 | +| :--- | :--- | :--- | :--- | |
| 42 | +| **operator** | `string` | ✅ | Aggregation operator (e.g., $match, $group, $sort) | |
| 43 | +| **options** | `Record<string, any>` | ✅ | Stage-specific options | |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## ConsistencyLevel |
| 48 | + |
| 49 | +### Allowed Values |
| 50 | + |
| 51 | +* `all` |
| 52 | +* `quorum` |
| 53 | +* `one` |
| 54 | +* `local_quorum` |
| 55 | +* `each_quorum` |
| 56 | +* `eventual` |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## DocumentValidationSchema |
| 61 | + |
| 62 | +### Properties |
| 63 | + |
| 64 | +| Property | Type | Required | Description | |
| 65 | +| :--- | :--- | :--- | :--- | |
| 66 | +| **enabled** | `boolean` | optional | Enable schema validation | |
| 67 | +| **validationLevel** | `Enum<'strict' \| 'moderate' \| 'off'>` | optional | Validation strictness | |
| 68 | +| **validationAction** | `Enum<'error' \| 'warn'>` | optional | Action on validation failure | |
| 69 | +| **jsonSchema** | `Record<string, any>` | optional | JSON Schema for validation | |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## NoSQLDataTypeMapping |
| 74 | + |
| 75 | +### Properties |
| 76 | + |
| 77 | +| Property | Type | Required | Description | |
| 78 | +| :--- | :--- | :--- | :--- | |
| 79 | +| **text** | `string` | ✅ | NoSQL type for text fields | |
| 80 | +| **number** | `string` | ✅ | NoSQL type for number fields | |
| 81 | +| **boolean** | `string` | ✅ | NoSQL type for boolean fields | |
| 82 | +| **date** | `string` | ✅ | NoSQL type for date fields | |
| 83 | +| **datetime** | `string` | ✅ | NoSQL type for datetime fields | |
| 84 | +| **json** | `string` | optional | NoSQL type for JSON/object fields | |
| 85 | +| **uuid** | `string` | optional | NoSQL type for UUID fields | |
| 86 | +| **binary** | `string` | optional | NoSQL type for binary fields | |
| 87 | +| **array** | `string` | optional | NoSQL type for array fields | |
| 88 | +| **objectId** | `string` | optional | NoSQL type for ObjectID fields (MongoDB) | |
| 89 | +| **geopoint** | `string` | optional | NoSQL type for geospatial point fields | |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## NoSQLDatabaseType |
| 94 | + |
| 95 | +### Allowed Values |
| 96 | + |
| 97 | +* `mongodb` |
| 98 | +* `couchdb` |
| 99 | +* `dynamodb` |
| 100 | +* `cassandra` |
| 101 | +* `redis` |
| 102 | +* `elasticsearch` |
| 103 | +* `neo4j` |
| 104 | +* `orientdb` |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## NoSQLDriverConfig |
| 109 | + |
| 110 | +### Properties |
| 111 | + |
| 112 | +| Property | Type | Required | Description | |
| 113 | +| :--- | :--- | :--- | :--- | |
| 114 | +| **name** | `string` | ✅ | Driver instance name | |
| 115 | +| **type** | `string` | ✅ | Driver type must be "nosql" | |
| 116 | +| **capabilities** | `object` | ✅ | Driver capability flags | |
| 117 | +| **connectionString** | `string` | optional | Database connection string (driver-specific format) | |
| 118 | +| **poolConfig** | `object` | optional | Connection pool configuration | |
| 119 | +| **databaseType** | `Enum<'mongodb' \| 'couchdb' \| 'dynamodb' \| 'cassandra' \| 'redis' \| 'elasticsearch' \| 'neo4j' \| 'orientdb'>` | ✅ | Specific NoSQL database type | |
| 120 | +| **dataTypeMapping** | `object` | ✅ | NoSQL data type mapping configuration | |
| 121 | +| **consistency** | `Enum<'all' \| 'quorum' \| 'one' \| 'local_quorum' \| 'each_quorum' \| 'eventual'>` | optional | Consistency level for operations | |
| 122 | +| **replication** | `object` | optional | Replication configuration | |
| 123 | +| **sharding** | `object` | optional | Sharding configuration | |
| 124 | +| **schemaValidation** | `object` | optional | Document schema validation | |
| 125 | +| **region** | `string` | optional | AWS region (for managed NoSQL services) | |
| 126 | +| **accessKeyId** | `string` | optional | AWS access key ID | |
| 127 | +| **secretAccessKey** | `string` | optional | AWS secret access key | |
| 128 | +| **ttlField** | `string` | optional | Field name for TTL (auto-deletion) | |
| 129 | +| **maxDocumentSize** | `integer` | optional | Maximum document size in bytes | |
| 130 | +| **collectionPrefix** | `string` | optional | Prefix for collection/table names | |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +## NoSQLIndex |
| 135 | + |
| 136 | +### Properties |
| 137 | + |
| 138 | +| Property | Type | Required | Description | |
| 139 | +| :--- | :--- | :--- | :--- | |
| 140 | +| **name** | `string` | ✅ | Index name | |
| 141 | +| **type** | `Enum<'single' \| 'compound' \| 'unique' \| 'text' \| 'geospatial' \| 'hashed' \| 'ttl' \| 'sparse'>` | ✅ | Index type | |
| 142 | +| **fields** | `object[]` | ✅ | Fields to index | |
| 143 | +| **unique** | `boolean` | optional | Enforce uniqueness | |
| 144 | +| **sparse** | `boolean` | optional | Sparse index | |
| 145 | +| **expireAfterSeconds** | `integer` | optional | TTL in seconds | |
| 146 | +| **partialFilterExpression** | `Record<string, any>` | optional | Partial index filter | |
| 147 | +| **background** | `boolean` | optional | Create index in background | |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +## NoSQLIndexType |
| 152 | + |
| 153 | +### Allowed Values |
| 154 | + |
| 155 | +* `single` |
| 156 | +* `compound` |
| 157 | +* `unique` |
| 158 | +* `text` |
| 159 | +* `geospatial` |
| 160 | +* `hashed` |
| 161 | +* `ttl` |
| 162 | +* `sparse` |
| 163 | + |
| 164 | +--- |
| 165 | + |
| 166 | +## NoSQLOperationType |
| 167 | + |
| 168 | +### Allowed Values |
| 169 | + |
| 170 | +* `find` |
| 171 | +* `findOne` |
| 172 | +* `insert` |
| 173 | +* `update` |
| 174 | +* `delete` |
| 175 | +* `aggregate` |
| 176 | +* `mapReduce` |
| 177 | +* `count` |
| 178 | +* `distinct` |
| 179 | +* `createIndex` |
| 180 | +* `dropIndex` |
| 181 | + |
| 182 | +--- |
| 183 | + |
| 184 | +## NoSQLQueryOptions |
| 185 | + |
| 186 | +### Properties |
| 187 | + |
| 188 | +| Property | Type | Required | Description | |
| 189 | +| :--- | :--- | :--- | :--- | |
| 190 | +| **consistency** | `Enum<'all' \| 'quorum' \| 'one' \| 'local_quorum' \| 'each_quorum' \| 'eventual'>` | optional | Consistency level override | |
| 191 | +| **readFromSecondary** | `boolean` | optional | Allow reading from secondary replicas | |
| 192 | +| **projection** | `Record<string, Enum<'0' \| '1'>>` | optional | Field projection | |
| 193 | +| **timeout** | `integer` | optional | Query timeout (ms) | |
| 194 | +| **useCursor** | `boolean` | optional | Use cursor instead of loading all results | |
| 195 | +| **batchSize** | `integer` | optional | Cursor batch size | |
| 196 | +| **profile** | `boolean` | optional | Enable query profiling | |
| 197 | +| **hint** | `string` | optional | Index hint for query optimization | |
| 198 | + |
| 199 | +--- |
| 200 | + |
| 201 | +## NoSQLTransactionOptions |
| 202 | + |
| 203 | +### Properties |
| 204 | + |
| 205 | +| Property | Type | Required | Description | |
| 206 | +| :--- | :--- | :--- | :--- | |
| 207 | +| **readConcern** | `Enum<'local' \| 'majority' \| 'linearizable' \| 'snapshot'>` | optional | Read concern level | |
| 208 | +| **writeConcern** | `Enum<'majority' \| 'acknowledged' \| 'unacknowledged'>` | optional | Write concern level | |
| 209 | +| **readPreference** | `Enum<'primary' \| 'primaryPreferred' \| 'secondary' \| 'secondaryPreferred' \| 'nearest'>` | optional | Read preference | |
| 210 | +| **maxCommitTimeMS** | `integer` | optional | Transaction commit timeout (ms) | |
| 211 | + |
| 212 | +--- |
| 213 | + |
| 214 | +## ReplicationConfig |
| 215 | + |
| 216 | +### Properties |
| 217 | + |
| 218 | +| Property | Type | Required | Description | |
| 219 | +| :--- | :--- | :--- | :--- | |
| 220 | +| **enabled** | `boolean` | optional | Enable replication | |
| 221 | +| **replicaSetName** | `string` | optional | Replica set name | |
| 222 | +| **replicas** | `integer` | optional | Number of replicas | |
| 223 | +| **readPreference** | `Enum<'primary' \| 'primaryPreferred' \| 'secondary' \| 'secondaryPreferred' \| 'nearest'>` | optional | Read preference for replica set | |
| 224 | +| **writeConcern** | `Enum<'majority' \| 'acknowledged' \| 'unacknowledged'>` | optional | Write concern level | |
| 225 | + |
| 226 | +--- |
| 227 | + |
| 228 | +## ShardingConfig |
| 229 | + |
| 230 | +### Properties |
| 231 | + |
| 232 | +| Property | Type | Required | Description | |
| 233 | +| :--- | :--- | :--- | :--- | |
| 234 | +| **enabled** | `boolean` | optional | Enable sharding | |
| 235 | +| **shardKey** | `string` | optional | Field to use as shard key | |
| 236 | +| **shardingStrategy** | `Enum<'hash' \| 'range' \| 'zone'>` | optional | Sharding strategy | |
| 237 | +| **numShards** | `integer` | optional | Number of shards | |
| 238 | + |
0 commit comments