Registry / database / mongodb-anonymizer

mongodb-anonymizer

JSON →
library0.3.1jsnpmunverified

A CLI tool for exporting a MongoDB database from a source URI to a target URI while anonymizing sensitive fields using faker. Current stable version 0.3.1. Release cadence: sporadic, last update 2023. Key differentiators: No installation required (npx), automatically detects field names for faker functions, supports custom mappings and static values. Targets Node >=8.0.0.

npm install mongodb-anonymizer
INSTALL
IMPORT
SIG · MONGODB-ANONYMIZER
M
mongodb-anonymizer
databasejavascriptv0.3.1
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.

cli (main command)
npx mongodb-anonymizer --uri=... --targetUri=...
npm install -g mongodb-anonymizer && mongodb-anonymizer (not needed but works)
Use npx to run without installing globally. Package does not expose a programmatic API, only CLI.
require('mongodb-anonymizer')
N/A – no programmatic API
const anonymizer = require('mongodb-anonymizer')
This package is CLI-only; there is no exported module for programmatic use.
Type definitions
No separate type import needed; types are bundled with package.
None
TypeScript types are included but only for internal usage, not exposed to consumers.

Runs the CLI tool via npx, connecting to a source MongoDB and copying to target with anonymization of specified fields.

npx mongodb-anonymizer --uri=mongodb://localhost:27017/source --targetUri=mongodb://localhost:27017/anonymized --list=email,firstName,lastName,phone
Debug
Known issues
gotchaTarget collections will be dropped before replacement.
fix
Ensure target database is a copy or has backups.
affects: <0.4.0
deprecatedPackage uses @faker-js/faker v6 (old namespace) which is deprecated; newer versions use @faker-js/faker with different exports.
fix
Pin faker version to v6 or update code for faker v7+.
affects: >=0.3.0
gotchaIf --list is not provided, default anonymized fields may not match your schema.
fix
Always specify --list with your field names.
affects: >=0.1.0
breakingNode.js >=8.0.0 required. Using older Node versions will fail.
fix
Update Node.js to v8 or higher.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module '@faker-js/faker'
Faker dependency not installed when using npx without local install.
fix
Ensure you have internet connectivity; npx will auto-install. If behind proxy, manually install with 'npm install -g mongodb-anonymizer'.
MongoNetworkError: failed to connect to server [localhost:27017]
MongoDB not running or URI incorrect.
fix
Start MongoDB service or check your --uri and --targetUri connection strings.
TypeError: Cannot read properties of null (reading 'collections')
Source database does not exist or is empty.
fix
Specify a valid source database URI.
Error: Collection <name> already exists
Target database has existing collections that conflict with drop operation.
fix
Ensure target database is empty or use a different target name.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies
@oclif/commandrequiredCLI framework dependency
mongodbrequiredMongoDB driver for connecting to source and target databases
@faker-js/fakerrequiredProvides fake data generation for anonymization
Agent activity
16 hits · last 30 days
node
14
Resources
mongodb-anonymizer — npm install mongodb-anonymizer · libregistry