Driver Mongo schema — Data Protocol reference
Describes the MongoDB connection settings and capabilities. ENFORCED as of #4410.
MongoDB Standard Driver Protocol
Describes the MongoDB connection settings and capabilities.
ENFORCED as of #4410. This block used to claim it was "used by the Platform
to validate datasource.config when driver: 'mongo'", which was false: the
config slot was a bare z.record and this schema had no consumer at all —
not even an export, since data/driver/ was reachable only from its own
tests. It is now what DatasourceSchema parses config against for a mongo
datasource, and the same schema is projected onto
MongoDriverSpec.configSchema for the connection form.
Source: packages/spec/src/data/driver/mongo.zod.ts
TypeScript Usage
import { MongoConfigSchema } from '@objectstack/spec/data';
import type { MongoConfig } from '@objectstack/spec/data';
// Validate data
const result = MongoConfigSchema.parse(data);MongoConfig
MongoDB Connection Configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| url | string | optional | Connection URI (supersedes the discrete fields; must not embed a password — bind the secret instead) |
| database | string | optional | Database name |
| host | string | optional (default: "localhost") | Host address |
| port | integer | optional (default: 27017) | Port number |
| username | string | optional | Authentication user |
| password | never | optional | Set through the connection form's secret field or external.credentialsRef — encrypted into sys_secret, never stored in config. A datasource defined in code (defineDatasource) leaves the credential out of the declaration: it is read at connect time from the runtime environment variable derived from the datasource name (OS_DATASOURCE_WAREHOUSE_PASSWORD for a datasource named warehouse), which os serve / os start honour by default (OS_DATASOURCE_ENV_CREDENTIALS=on). |
| authSource | string | optional | Authentication database |
| options | Record<string, any> | optional | Extra MongoClient options (replicaSet, tls, timeouts, …). Credential-spelled keys (password, authToken, and their former aliases) are refused inline at any depth — bind the secret via the connection form / external.credentialsRef. proxyPassword, tlsCertificateKeyFilePassword, key, and passphrase are accepted and stored at rest in cleartext; they're redacted only when the datasource is read back, not refused at write. |