ObjectStackObjectStack

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

PropertyTypeRequiredDescription
urlstringoptionalConnection URI (supersedes the discrete fields; must not embed a password — bind the secret instead)
databasestringoptionalDatabase name
hoststringoptional (default: "localhost")Host address
portintegeroptional (default: 27017)Port number
usernamestringoptionalAuthentication user
passwordneveroptionalSet through the connection form's secret field or external.credentialsRef — encrypted into sys_secret, never stored in config (#7990)
authSourcestringoptionalAuthentication database
optionsRecord<string, any>optionalExtra 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.

On this page