{"id":20560005,"url":"https://github.com/mikeyburkman/rhmap-mongodb","last_synced_at":"2026-04-21T13:34:07.473Z","repository":{"id":67371510,"uuid":"76392022","full_name":"MikeyBurkman/rhmap-mongodb","owner":"MikeyBurkman","description":"Mongodb Promise wrapper for RHMAP","archived":false,"fork":false,"pushed_at":"2017-05-18T15:57:40.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-06T07:46:49.107Z","etag":null,"topics":["mongodb","rhmap","rhmap-mongodb"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MikeyBurkman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-13T19:37:50.000Z","updated_at":"2017-07-12T18:29:19.000Z","dependencies_parsed_at":"2023-02-22T04:45:10.608Z","dependency_job_id":null,"html_url":"https://github.com/MikeyBurkman/rhmap-mongodb","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/MikeyBurkman/rhmap-mongodb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeyBurkman%2Frhmap-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeyBurkman%2Frhmap-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeyBurkman%2Frhmap-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeyBurkman%2Frhmap-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikeyBurkman","download_url":"https://codeload.github.com/MikeyBurkman/rhmap-mongodb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeyBurkman%2Frhmap-mongodb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32094639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T11:25:29.218Z","status":"ssl_error","status_checked_at":"2026-04-21T11:25:28.499Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["mongodb","rhmap","rhmap-mongodb"],"created_at":"2024-11-16T03:52:50.719Z","updated_at":"2026-04-21T13:34:07.449Z","avatar_url":"https://github.com/MikeyBurkman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rhmap-mongodb\nMongodb Promise wrapper for RHMAP\n\n## Purpose\n- Connects to Mongodb on the RHMAP platform, retrying indefinitely if necessary, in the case of the DB being down.\n- Exposes a collection function that provides all Mongodb colleciton functions,\nexcept wrapped in [Bluebird](https://www.npmjs.com/package/bluebird) promise for ease of use.\n- Also exposes the raw connected MongoClient, if necessary.\n- Node 0.10 compliant (for now)\n\n## Usage\nFirst of all, you need to make sure your database on RHMAP has been \"upgraded\". Go to the Data Browser, and click \"Upgrade Database\". This will restart your application, and allow your application to connect directly to the database instead of through `$fh.db`.\n\n```js\nvar mongo = require('rhmap-mongodb');\n\nvar collection = mongo.collection('MY_COLLECTION');\n\nexports.createRecord = function createRecord(record) {\n    return collection.insert(record);\n};\n```\n\n## API\n`collection(collectionName)` - Returns an object containing all collection functions that\nthe mongodb module provides. IE: `find()`, `insert()`, `remove()`, etc.\n**These functions all return strict Bluebird promises**, even if the original mongodb functions did not. (See below caveats for more details.)\n```js\nmongo.collection('FOO')\n    .find({status: 'successs'}) // Call the find() mongodb collection function\n    .then((cursor) =\u003e cursor.toArray())\n    .map((successRecord) =\u003e log.debug('Processed record: ', successRecord)); // Returns a bluebird promise, so we can use its utility functions.\n```\n\n`db()` - Returns a **promise** that resolves to the connected Mongodb driver.\nThis returns the equivalent of calling `MongoClient.connect(url)`.\n\n`mongodb` - This is a property that exposes the underlying `mongodb` module this module uses internally.\n\n## Configuration\nConfiguration is done via environment variables:\n\n`FH_MONGODB_CONN_URL` - This is the URL for connecting to Mongo. This is set automatically by the RHMAP platform. Defaults to `mongodb://localhost:27017/FH_LOCAL`\n\n`RHMAP_MONGO_CONNECT_RETRY_INTERVAL` - This is the number of milliseconds between retries if the Mongo database is not immediately available. Defaults to `10000` (10 seconds)\n\n## Caveats\nOne thing to note is that functions like `find()` in the standard mongodb driver return a cursor object, whereas in rhmap-mongodb, `find()` will return a (Bluebird) promise that *resolves* to a cursor.\n```js\n// Legal in the standard mongodb driver, but will NOT work with rhmap-mongo\nstandardmongo.collection('foo')\n    .find()\n    .sort({date: 1})\n    .toArray()\n    .then((resultsArray) =\u003e ...);\n\n// Instead you must call functions on the resolved cursor\nrhampmongo.collection('foo')\n    .find()\n    .then((cursor) =\u003e cursor.sort({date: 1}).toArray())\n    .then((resultsArray) =\u003e ...);\n```\n\n## Contributing\n\n### Testing\nJust run `npm test`. You must have a version of Mongodb running locally.\nThe preferred version is 2.4.6, as that is what RHMAP currently runs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeyburkman%2Frhmap-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikeyburkman%2Frhmap-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeyburkman%2Frhmap-mongodb/lists"}