{"id":18615029,"url":"https://github.com/andrewjbateman/example-mongodb-connection","last_synced_at":"2026-04-28T18:04:21.720Z","repository":{"id":96859124,"uuid":"135037039","full_name":"AndrewJBateman/example-mongodb-connection","owner":"AndrewJBateman","description":":clipboard: Connect to a dabase in mlab and add data then close db","archived":false,"fork":false,"pushed_at":"2022-03-25T12:36:31.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-17T01:34:32.321Z","etag":null,"topics":["javascript","mlab","mongodb-database"],"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/AndrewJBateman.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-27T10:39:05.000Z","updated_at":"2022-03-25T12:36:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"ee1a7aa5-3bd1-494f-a629-ec26c4792ca9","html_url":"https://github.com/AndrewJBateman/example-mongodb-connection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AndrewJBateman/example-mongodb-connection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fexample-mongodb-connection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fexample-mongodb-connection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fexample-mongodb-connection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fexample-mongodb-connection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndrewJBateman","download_url":"https://codeload.github.com/AndrewJBateman/example-mongodb-connection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fexample-mongodb-connection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32392315,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: 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":["javascript","mlab","mongodb-database"],"created_at":"2024-11-07T03:27:53.169Z","updated_at":"2026-04-28T18:04:21.689Z","avatar_url":"https://github.com/AndrewJBateman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :zap: Example MongoDB Connection\n\n* This app connects to a MongoDB database, creates a collection, populates it with items, then drops the collection and closes the connection.\n* Credit to Anish Karandikar (anishkny) who wrote the original code. I have taken it to modify and play with so I learn how to use a mlab mongodb database.\n* Note: mLab MongoDB Heroku add-on has been shut down - suggest MongoDB Atlas (free tier) is used instead\n* **Note:** to open web links in a new window use: _ctrl+click on link_\n\n![GitHub repo size](https://img.shields.io/github/repo-size/AndrewJBateman/example-mongodb-connection?style=plastic)\n![GitHub pull requests](https://img.shields.io/github/issues-pr/AndrewJBateman/example-mongodb-connection?style=plastic)\n![GitHub Repo stars](https://img.shields.io/github/stars/AndrewJBateman/example-mongodb-connection?style=plastic)\n![GitHub last commit](https://img.shields.io/github/last-commit/AndrewJBateman/example-mongodb-connection?style=plastic)\n\n## :page_facing_up: Table of contents\n\n* [:zap: FCC Mongo \u0026 Mongoose Challenges](#zap-fcc-mongo--mongoose-challenges)\n\t* [:page_facing_up: Table of contents](#page_facing_up-table-of-contents)\n\t* [:books: General info](#books-general-info)\n\t* [:signal_strength: Technologies](#signal_strength-technologies)\n\t* [:floppy_disk: Setup](#floppy_disk-setup)\n\t* [:computer: Code Examples](#computer-code-examples)\n\t* [:cool: Features](#cool-features)\n\t* [:clipboard: Status \u0026 To-Do List](#clipboard-status--to-do-list)\n\t* [:clap: Inspiration](#clap-inspiration)\n\t* [:file_folder: License](#file_folder-license)\n\t* [:envelope: Contact](#envelope-contact)\n\n## :books: General info\n\n* Database methods used: insert, update, find, drop and close\n* Example: [MongoDB insert method](https://docs.mongodb.com/manual/reference/method/db.collection.insert/) used to insert a song document into a songs collection\n\n## :signal_strength: Technologies\n\n* [Express v4](https://expressjs.com/) Fast, unopinionated, minimalist web framework for Node.js\n* [MongoDB Atlas](https://www.mongodb.com/cloud/atlas)\n* [mongoose v5](https://mongoosejs.com/) object modelling for node.js.\n\n## :floppy_disk: Setup\n\n* Create MongoDB Atlas Cloud database (or local installed MongoDB database)\n* Add PORT number and user access/database credentials to create database url(USER_NAME, USER_PASSWORD, DB_CLUSTER, PORT, DB_NAME \u0026 SESSION_SECRET) to a new `.env` file. These are used in `server.js`.\n* Add your IP address to MongoDB Atlas Network Access whitelist. Or simply whitelist all (IP address 0.0.0.0/0).\n* Run `npm run start` or `node server.js` for a dev server.\n* Navigate to `http://localhost:4000/` (or other port selected/default port 3000) for home screen.\n* The app will not automatically reload if you change any of the source files.\n\n## :computer: Code Examples\n\n* extract from `server.js` to close database\n\n```javascript\n// Only close the connection when your app is terminating.\ndb.close(function (err) {\n\tdbSongs += 'Closing db ' + process.env.DB;\n\tdbSongs +=\n\t\t'\u003cscript src=\"https://button.glitch.me/button.js\" data-style=\"glitch\"\u003e\u003c/script\u003e\u003cdiv class=\"glitchButton\" style=\"position:fixed;top:20px;right:20px;\"\u003e\u003c/div\u003e';\n\tif (err) throw err;\n});\n```\n\n## :cool: Features\n\n* Nothing cool. MongoDB collection methods have changed - this is old code\n\n## :clipboard: Status \u0026 To-Do List\n\n* Status: Working with original dependency versions\n* To-Do: Update with latest database access methods\n\n## :clap: Inspiration\n\n* [Github code: Anish Karandikar](https://github.com/anishkny)\n\n## :file_folder: License\n\n* N/A\n\n## :envelope: Contact\n\n* Repo created by [ABateman](https://github.com/AndrewJBateman), email: gomezbateman@yahoo.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewjbateman%2Fexample-mongodb-connection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewjbateman%2Fexample-mongodb-connection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewjbateman%2Fexample-mongodb-connection/lists"}