Driver Mongo
Driver Mongo protocol schemas
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 (#7990) |
| authSource | string | optional | Authentication database |
| options | Record<string, any> | optional | Extra MongoClient options (replicaSet, tls, timeouts, …). Only auth.password is refused inline — bind it 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. |