{"_id":"@ashkiani/mongo-client","_rev":"2-dc4d48e76b518b33640d55388cc6b465","name":"@ashkiani/mongo-client","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@ashkiani/mongo-client","version":"1.0.0","keywords":["mongodb","client","connection","nodejs","utility"],"author":{"name":"Siavash Ashkiani"},"license":"MIT","_id":"@ashkiani/mongo-client@1.0.0","maintainers":[{"name":"ashkiani","email":"ashkiani@yahoo.com"}],"homepage":"https://github.com/ashkiani/mongo-client#readme","bugs":{"url":"https://github.com/ashkiani/mongo-client/issues"},"dist":{"shasum":"0e7381e49d3b3327971faddcb88b43e5f2297db4","tarball":"https://registry.npmjs.org/@ashkiani/mongo-client/-/mongo-client-1.0.0.tgz","fileCount":5,"integrity":"sha512-gBTWqFb29y1NNxPwxFulEfGRHUBuKK8hjHaRiXQRxbJSXbJcBsfC/qWDJdvo5eFS43WcxigNNRGAebCt9X4NnA==","signatures":[{"sig":"MEQCIDuItqx1NrwAqTseaRJOqEv18noZ//83OihlkUKeaPo7AiBlDlB7GKqy/CWjpL1l8suW2jnVQcZx+DCrp35VA7lZCw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3856},"main":"index.js","gitHead":"6fd2e0d11d81e3e3cd28521436e6772d551dee1f","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"ashkiani","email":"ashkiani@yahoo.com"},"repository":{"url":"git+https://github.com/ashkiani/mongo-client.git","type":"git"},"_npmVersion":"9.2.0","description":"Reusable MongoDB client utility for Node.js projects","directories":{},"_nodeVersion":"20.19.0","dependencies":{"mongodb":"^6.16.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mongo-client_1.0.0_1746489575964_0.8502969291021385","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@ashkiani/mongo-client","version":"1.0.1","description":"Reusable MongoDB client utility for Node.js projects","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ashkiani/mongo-client.git"},"keywords":["mongodb","client","connection","nodejs","utility"],"author":{"name":"Siavash Ashkiani"},"license":"MIT","bugs":{"url":"https://github.com/ashkiani/mongo-client/issues"},"homepage":"https://github.com/ashkiani/mongo-client#readme","dependencies":{"dotenv":"^16.5.0","mongodb":"^6.16.0"},"gitHead":"687d66d17b31f9cdbfbacb8ae4a0bd4784aa7603","_id":"@ashkiani/mongo-client@1.0.1","_nodeVersion":"20.19.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-kCjH2Eoz4gWpubyWJs/VkTibQL11bbqRjnNgPoxBei9yizYqtARnW6ygdMu1jaCxAWrBI4THfMsY/vDSJLceig==","shasum":"bb7b0e6b6af53218324b8aaa9f0fa453d40c3ae4","tarball":"https://registry.npmjs.org/@ashkiani/mongo-client/-/mongo-client-1.0.1.tgz","fileCount":5,"unpackedSize":3881,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEYmE/p+/TruqPFz3WVy5A1Od/sNlAqlapwPaZNn+yyNAiAqgZ9KKebIJoTJPHIYW1bPNCi6Gy/mzwL2T6T+i9XqZw=="}]},"_npmUser":{"name":"ashkiani","email":"ashkiani@yahoo.com"},"directories":{},"maintainers":[{"name":"ashkiani","email":"ashkiani@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mongo-client_1.0.1_1746534410051_0.5163799785580845"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-05T23:59:35.818Z","modified":"2025-05-06T12:26:50.416Z","1.0.0":"2025-05-05T23:59:36.147Z","1.0.1":"2025-05-06T12:26:50.228Z"},"bugs":{"url":"https://github.com/ashkiani/mongo-client/issues"},"author":{"name":"Siavash Ashkiani"},"license":"MIT","homepage":"https://github.com/ashkiani/mongo-client#readme","keywords":["mongodb","client","connection","nodejs","utility"],"repository":{"type":"git","url":"git+https://github.com/ashkiani/mongo-client.git"},"description":"Reusable MongoDB client utility for Node.js projects","maintainers":[{"name":"ashkiani","email":"ashkiani@yahoo.com"}],"readme":"# mongo-client\nReusable MongoDB client utility for Node.js projects.\n\n````markdown\n# @ashkiani/mongo-client\n\nReusable MongoDB client utility for Node.js projects.  \nProvides a simple and consistent way to connect, retrieve, and close a shared MongoDB client instance using environment-based configuration.\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @ashkiani/mongo-client\n````\n\n---\n\n## 🛠 Usage\n\n### 1. Set your environment variable:\n\nMake sure your project defines the MongoDB URI as:\n\n```\nMongo_URI=mongodb://username:password@host:port/dbname\n```\n\n---\n\n### 2. Import and use in your Node.js code:\n\n```js\nconst dbClient = require('@ashkiani/mongo-client');\n\n(async () => {\n    await dbClient.connect();  // establish connection once\n\n    const client = dbClient.get();\n    const collection = client.db('your-db-name').collection('your-collection');\n\n    const results = await collection.find({}).toArray();\n    console.log(results);\n\n    await dbClient.close();  // optional: close if shutting down app\n})();\n```\n\n---\n\n## 📘 API\n\n### `connect()`\n\nEstablishes a connection to MongoDB using the URI from `process.env.Mongo_URI`.\n\n### `get()`\n\nReturns the connected `MongoClient` instance for reuse.\n\n### `close()`\n\nCloses the MongoDB connection.\n\n---\n\n## 💡 Notes\n\n* This module is designed to be used as a singleton across your app.\n* Connection URI should be stored securely in environment variables (`.env` or your deployment config).\n* Built using the official [`mongodb`](https://www.npmjs.com/package/mongodb) package.\n\n---\n\n## 📄 License\n\nMIT © [Siavash Ashkiani](https://github.com/ashkiani)\n\n","readmeFilename":"README.md"}