{"id":17034554,"url":"https://github.com/caub/mongo-lazy-connect","last_synced_at":"2025-04-12T13:13:02.334Z","repository":{"id":57301522,"uuid":"108844008","full_name":"caub/mongo-lazy-connect","owner":"caub","description":":banana: Wrapper for MongoClient.connect for a lazy access to db","archived":false,"fork":false,"pushed_at":"2019-10-17T17:55:25.000Z","size":85,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T13:12:57.570Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-30T11:53:44.000Z","updated_at":"2023-11-06T11:28:54.000Z","dependencies_parsed_at":"2022-08-24T17:11:45.566Z","dependency_job_id":null,"html_url":"https://github.com/caub/mongo-lazy-connect","commit_stats":null,"previous_names":["caub/mongo-connect-sync"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caub%2Fmongo-lazy-connect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caub%2Fmongo-lazy-connect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caub%2Fmongo-lazy-connect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caub%2Fmongo-lazy-connect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caub","download_url":"https://codeload.github.com/caub/mongo-lazy-connect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571864,"owners_count":21126522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T08:43:57.098Z","updated_at":"2025-04-12T13:13:02.313Z","avatar_url":"https://github.com/caub.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![coverage status][codecov-image]][codecov-url]\n\nSimilarly to other DBs (like `const pool=new pg.Pool('pg://...'); pool.query('select ..').then(console.log)`), let's allow a lazy access to the MongoDB driver pool\n\n```js\nconst db = require('mongo-lazy-connect')('mongodb://localhost:27017/connect-test');\n\nconst coll = db.collection('foo');\ncoll.insertOne({bar: 2}).then(() =\u003e {\n\tcoll.find({}).limit(5).toArray().then(console.log);\n});\n```\n\nis equivalent to:\n\n```js\nconst mongo = require('mongodb');\n\nmongo('mongodb://localhost:27017')\n\t.then(client =\u003e {\n\t\tconst coll = client.db('connect-test').collection('foo');\n\t\tcoll.insertOne({bar: 2}).then(() =\u003e {\n\t\t\tcoll.find({}).limit(5).toArray().then(console.log);\n\t\t});\n\t});\n```\n\nNote: for local testing, add a user on the DB\n```sh\ndocker exec mongo-lazy-connect mongo admin --eval 'db.createUser({user: \"mlc\", pwd: \"hunter2\", roles: [{role: \"root\", db: \"admin\"}]})'\n```\n\n\n[npm-image]: https://img.shields.io/npm/v/mongo-lazy-connect.svg?style=flat-square\u0026maxAge=86400\n[npm-url]: https://www.npmjs.com/package/mongo-lazy-connect\n[travis-image]: https://img.shields.io/travis/caub/mongo-lazy-connect.svg?style=flat-square\u0026maxAge=86400\n[travis-url]: https://travis-ci.org/caub/mongo-lazy-connect\n[codecov-image]: https://img.shields.io/codecov/c/github/caub/mongo-lazy-connect.svg?style=flat-square\u0026maxAge=86400\n[codecov-url]: https://codecov.io/gh/caub/mongo-lazy-connect\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaub%2Fmongo-lazy-connect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaub%2Fmongo-lazy-connect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaub%2Fmongo-lazy-connect/lists"}