{"id":27437378,"url":"https://github.com/ryomendev/mongoose-mongodb","last_synced_at":"2026-01-23T18:31:09.997Z","repository":{"id":283606850,"uuid":"952321647","full_name":"RyomenDev/Mongoose-Mongodb","owner":"RyomenDev","description":"A comprehensive guide to Mongoose \u0026 MongoDB, covering MongoDB Compass, MongoDB Shell, and essential commands. Learn how to set up a MongoDB database, use Mongoose for schema modeling, and interact with MongoDB via Compass and Shell with CRUD operations.","archived":false,"fork":false,"pushed_at":"2025-03-21T10:47:42.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T20:38:00.552Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"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/RyomenDev.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":"2025-03-21T05:04:02.000Z","updated_at":"2025-03-21T10:47:45.000Z","dependencies_parsed_at":"2025-03-21T06:20:01.270Z","dependency_job_id":"af1edaf5-c1fb-4e3b-9443-1fb279493826","html_url":"https://github.com/RyomenDev/Mongoose-Mongodb","commit_stats":null,"previous_names":["ryomendev/mongoose-mongodb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RyomenDev/Mongoose-Mongodb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FMongoose-Mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FMongoose-Mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FMongoose-Mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FMongoose-Mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RyomenDev","download_url":"https://codeload.github.com/RyomenDev/Mongoose-Mongodb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyomenDev%2FMongoose-Mongodb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28697428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"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":[],"created_at":"2025-04-14T20:29:01.328Z","updated_at":"2026-01-23T18:31:09.979Z","avatar_url":"https://github.com/RyomenDev.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mongoose \u0026 MongoDB Guide 📌\n\nA comprehensive guide to **Mongoose \u0026 MongoDB**, covering **MongoDB Compass**, **MongoDB Shell**, and essential commands. Learn how to set up a MongoDB database, use Mongoose for schema modeling, and interact with MongoDB via Compass and Shell with CRUD operations.\n\n## 📌 Table of Contents\n- [MongoDB Installation](#-mongodb-installation)\n- [MongoDB Compass Guide](#-mongodb-compass-guide)\n- [MongoDB Shell Commands](#-mongodb-shell-commands)\n- [Mongoose Integration](#-mongoose-integration)\n- [CRUD Operations](#-crud-operations)\n- [Authentication \u0026 Security](#-authentication--security)\n\n---\n\n## 🚀 MongoDB Installation\n\n### **Windows**\n1. Download **MongoDB Community Edition** from [MongoDB Official Website](https://www.mongodb.com/try/download/community).\n2. Install MongoDB and choose the option **MongoDB Compass** (GUI for MongoDB).\n3. Start the MongoDB service using:  \n   ```sh\n   mongod\n   ```\n\n### **Linux/Mac**\n1. Install MongoDB using Homebrew:\n   ```sh\n   brew tap mongodb/brew\n   brew install mongodb-community@6.0\n   ```\n2. Start the MongoDB service:\n   ```sh\n   brew services start mongodb-community@6.0\n   ```\n\n---\n\n## 🖥️ MongoDB Compass Guide\n\n### **Connecting to MongoDB**\n1. Open **MongoDB Compass**.\n2. Click on **\"Connect\"** and enter the MongoDB URI:  \n   ```\n   mongodb://localhost:27017\n   ```\n3. Click **\"Connect\"** to access your MongoDB collections.\n\n### **Creating a Database**\n1. Click **\"Create Database\"**.\n2. Enter a **Database Name** and **Collection Name**.\n3. Click **\"Create\"**.\n\n### **Performing CRUD Operations in Compass**\n- **Insert Data:** Click on **\"Insert Document\"**, add JSON data, and save.\n- **Edit Data:** Click on a document, modify fields, and save.\n- **Delete Data:** Click on **\"Delete Document\"**.\n\n---\n\n## 📜 MongoDB Shell Commands\n\n### **Basic Commands**\n```sh\nmongo  # Open MongoDB shell\nshow dbs  # List all databases\nuse myDatabase  # Switch to a database\ndb.createCollection(\"users\")  # Create a collection\nshow collections  # Show all collections\n```\n\n### **CRUD Operations**\n#### **Insert a Document**\n```sh\ndb.users.insertOne({ name: \"John Doe\", email: \"john@example.com\" })\ndb.users.insertMany([{ name: \"Alice\" }, { name: \"Bob\" }])\n```\n\n#### **Read Documents**\n```sh\ndb.users.find()  # Find all documents\ndb.users.findOne({ name: \"John Doe\" })  # Find one document\n```\n\n#### **Update a Document**\n```sh\ndb.users.updateOne({ name: \"John Doe\" }, { $set: { email: \"john.doe@example.com\" } })\n```\n\n#### **Delete a Document**\n```sh\ndb.users.deleteOne({ name: \"John Doe\" })\n```\n\n---\n\n## ⚡ Mongoose Integration\n\n### **Install Mongoose**\n```sh\nnpm install mongoose\n```\n\n### **Connect to MongoDB**\n```javascript\nconst mongoose = require(\"mongoose\");\n\nmongoose.connect(\"mongodb://localhost:27017/myDatabase\", {\n  useNewUrlParser: true,\n  useUnifiedTopology: true,\n}).then(() =\u003e console.log(\"MongoDB Connected\"))\n  .catch(err =\u003e console.error(err));\n```\n\n### **Create a Mongoose Schema**\n```javascript\nconst userSchema = new mongoose.Schema({\n  name: String,\n  email: String,\n  password: String,\n});\n\nconst User = mongoose.model(\"User\", userSchema);\n```\n\n---\n\n## 🛠️ CRUD Operations with Mongoose\n\n### **Create a User**\n```javascript\nconst newUser = new User({ name: \"John\", email: \"john@example.com\", password: \"12345\" });\nawait newUser.save();\n```\n\n### **Read Users**\n```javascript\nconst users = await User.find();\nconsole.log(users);\n```\n\n### **Update a User**\n```javascript\nawait User.updateOne({ name: \"John\" }, { $set: { email: \"newemail@example.com\" } });\n```\n\n### **Delete a User**\n```javascript\nawait User.deleteOne({ name: \"John\" });\n```\n\n---\n\n## 🔐 Authentication \u0026 Security\n- Use **bcrypt** for password hashing:\n  ```sh\n  npm install bcrypt\n  ```\n  ```javascript\n  const bcrypt = require(\"bcrypt\");\n  const hashedPassword = await bcrypt.hash(\"myPassword\", 10);\n  ```\n- Use **JWT** for authentication:\n  ```sh\n  npm install jsonwebtoken\n  ```\n  ```javascript\n  const jwt = require(\"jsonwebtoken\");\n  const token = jwt.sign({ userId: user._id }, \"secretkey\", { expiresIn: \"1h\" });\n  ```\n\n---\n\n## 🏗️ Tech Stack\n- **Database:** MongoDB\n- **ODM:** Mongoose\n- **Backend:** Node.js, Express.js\n- **Security:** JWT, bcrypt\n\n## 🤝 Contributing\nFeel free to submit **issues** and **pull requests**! Contributions are always welcome.  \n\n## 📜 License\nThis project is open-source and available under the **MIT License**.\n\n---\n\n🚀 **Happy Learning!** 🎯\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryomendev%2Fmongoose-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryomendev%2Fmongoose-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryomendev%2Fmongoose-mongodb/lists"}