Registry / database / zod-dbs-mongodb

zod-dbs-mongodb

JSON →
library1.0.5jsnpmunverified

MongoDB provider for zod-dbs, a tool that generates Zod schemas from database schemas. Version 1.0.5 requires `mongodb` (>=5) peer dependency. It introspects a MongoDB database (sampling documents) to infer schema types and generate type-safe Zod validation schemas. Key differentiator: works with existing MongoDB databases to produce TypeScript-first schemas without manual definition. Release cadence is low; the package is in early stages. Enum types are not yet supported.

npm install zod-dbs-mongodb
INSTALL
IMPORT
SIG · ZOD-DBS-MONGODB
Z
zod-dbs-mongodb
databasejavascriptv1.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createProvider
import { createProvider } from 'zod-dbs-mongodb'
const { createProvider } = require('zod-dbs-mongodb')
Package is ESM-only; CommonJS require will fail.

Generates Zod schemas from a MongoDB database using environment variables for credentials.

import { generateZodSchemas } from 'zod-dbs'; import { createProvider } from 'zod-dbs-mongodb'; await generateZodSchemas({ provider: createProvider(), config: { host: process.env.MONGO_HOST ?? 'localhost', database: process.env.MONGO_DB ?? 'mydb', user: process.env.MONGO_USER ?? '', password: process.env.MONGO_PASSWORD ?? '', }, });
Debug
Known issues
gotchaEnum types are not yet supported and will be omitted from generated schemas.
fix
Add enum fields to schemas manually after generation or use hooks.
affects: <=1.0.5
gotchaSchema generation relies on sampling documents; small or non-representative samples may produce incomplete or inaccurate schemas.
fix
Increase sample size via --sample-size or config.sampleSize.
affects: <=1.0.5
deprecatedThe package uses peerDependencies; if your npm version is <7, peer deps are not auto-installed.
fix
Manually install mongodb with npm install mongodb.
affects: *
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'zod-dbs-mongodb'
Package is ESM-only and cannot be required via require().
fix
Use import statement or configure ESM (type: module in package.json).
Missing required peer dependency: mongodb
mongodb package not installed.
fix
Run npm install mongodb.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
mongodbrequiredPeer dependency, required for database connection.
Agent activity
38 hits · last 30 days
node
32
OpenAI (training)
1
Resources
zod-dbs-mongodb — npm install zod-dbs-mongodb · libregistry