MongoDB namespace parsing and validation library that splits strings like 'db.collection' into components, checks validity, and identifies special namespaces (oplog, system, command). Current version 3.2.0, published under the @mongodb-js scope. Actively maintained as part of MongoDB DevTools Shared. Differentiators: strict validation of database and collection names per MongoDB rules, hash generation, and support for dotted collection names.
npm install mongodb-nsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Parses a MongoDB namespace string into its components, checks validity.
Use import syntax instead of require(). If you must use require(), use dynamic import() or upgrade to ESM.
Use default import: import parseNamespace from 'mongodb-ns'.
Use parseNamespace('db.collection') instead of new NS('db.collection').Always provide a string in 'database.collection' format. For system collections, use prefix 'system.'
Ensure your namespace follows MongoDB naming rules; use ns.validDatabaseName and ns.validCollectionName to check.
Change to import ns from 'mongodb-ns' or use dynamic import()
Run npm install mongodb-ns and ensure Node.js >=12 for ESM support.
Use parseNamespace(ns) which returns an object, not the raw string.
No dependency data recorded yet.