{"id":18171329,"url":"https://github.com/yajatkaul/go-mongoose","last_synced_at":"2026-02-12T09:03:22.879Z","repository":{"id":260275136,"uuid":"880838973","full_name":"yajatkaul/go-mongoose","owner":"yajatkaul","description":"Mongoose wrapper for mongodb but for GoLang","archived":false,"fork":false,"pushed_at":"2024-11-02T07:02:42.000Z","size":65,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T12:18:28.415Z","etag":null,"topics":["database","go","golang","library","mongodb","wrapper"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/yajatkaul/go-mongoose","language":"Go","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/yajatkaul.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":"2024-10-30T13:07:02.000Z","updated_at":"2025-01-07T20:22:29.000Z","dependencies_parsed_at":"2024-12-20T20:53:45.129Z","dependency_job_id":null,"html_url":"https://github.com/yajatkaul/go-mongoose","commit_stats":{"total_commits":51,"total_committers":1,"mean_commits":51.0,"dds":0.0,"last_synced_commit":"5e6b30940aedb4ffb32eecf361b9cef9de2a6a52"},"previous_names":["yajatkaul/go-mongoose"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yajatkaul%2Fgo-mongoose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yajatkaul%2Fgo-mongoose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yajatkaul%2Fgo-mongoose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yajatkaul%2Fgo-mongoose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yajatkaul","download_url":"https://codeload.github.com/yajatkaul/go-mongoose/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247621105,"owners_count":20968374,"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":["database","go","golang","library","mongodb","wrapper"],"created_at":"2024-11-02T15:08:42.143Z","updated_at":"2026-02-12T09:03:22.834Z","avatar_url":"https://github.com/yajatkaul.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Mongoose\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/yajatkaul/go-mongoose)](https://goreportcard.com/report/github.com/yajatkaul/go-mongoose)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n**Go Mongoose** is a lightweight MongoDB wrapper for Go, inspired by Mongoose, designed to simplify database operations and improve code readability.\n\n## Features\n\n- **Simple API**: Intuitive functions for common database operations.\n- **Populate**: Easily reference and populate fields from related collections.\n- **Flexible**: Supports various MongoDB operations including Create, Read, Update, and Delete (CRUD).\n\n## Installation\n\nTo install Go Mongoose, use the following command:\n\n```bash\ngo get github.com/yajatkaul/go-mongoose\ngo mod tidy\n```\n\n## Getting Started\nHere’s a quick guide to get you started with Go Mongoose.\n\n# 1. Connect to the Database\nBefore performing any operations, you need to connect to your MongoDB database. Here's an example of how to connect:\n```bash\npackage main\n\nimport (\n    MongoDBConnection \"github.com/yajatkaul/go-mongoose/MongoDBConnection\"\n)\n\nfunc init() {\n    // Connect to the MongoDB database\n    MongoDBConnection.Connect(\"uri\", \"Database Name\")\n}\n```\n\n# 2. Performing Operations\nGo Mongoose provides several functions to interact with your collections. Below are some common operations:\n  ```bash\n  //filter and updates are just JSON formats\n  filter := `{\"displayName\": \"Yajat\",\"email\":\"def@sds.com\"}`\n  update := `{\"displayName\": \"Yajat2\", \"email\":\"abc@sds.com\"}`\n  ```\n* Create a Document: Insert a document into a collection.\n  ```bash\n  mongoose.Create(\"collectionName\", filter) // filter is the document to insert\n  ```\n* Find Documents: Retrieve documents from a collection.\n  ```bash\n  val := mongoose.Find(\"collectionName\", filter) // Returns []bson.M\n  ```\n* Find One Document: Retrieve a single document.\n  ```bash\n  val := mongoose.FindOne(\"collectionName\", filter) // Returns bson.M\n  ```\n* Update a Document: Update a single document.\n  ```bash\n  mongoose.FindOneAndUpdate(\"collectionName\", filter, update)\n  ```\n* Delete a Document: Remove a single document.\n  ```bash\n  mongoose.FindOneAndDelete(\"collectionName\", filter)\n  ```\n* Find and Delete Multiple Documents: Find and delete all matching documents.\n  ```bash\n  mongoose.FindAllAndDelete(\"collectionName\", filter)\n  ```\n* Find and Update Multiple Documents: Find and update all matching documents.\n  ```bash\n  mongoose.FindAllAndUpdate(\"collectionName\", filter, update)\n  ```\n# 3. Populating References\nYou can easily populate fields from related collections:\n* Populate a Single Reference:\n  ```bash\n  document := mongoose.FindOne(\"collectionName\")\n  fmt.Println(mongoose.Populate(\"Name of the field to Populate\", \"Refference with which you want to populate\", document))\n  ```\n* Populate All References:\n  ```bash\n  document := mongoose.Find(\"collectionName\")\n  fmt.Println(mongoose.PopulateAll(\"Name of the field to Populate\", \"Refference with which you want to populate\", document))\n  ```\n## Example Usage\nHere’s a complete example demonstrating the usage of Go Mongoose:\n```bash\npackage main\n\nimport (\n    \"fmt\"\n    MongoDBConnection \"github.com/yajatkaul/go-mongoose/MongoDBConnection\"\n\t\"github.com/yajatkaul/go-mongoose/mongoose\"\n)\n\nfunc init() {\n    // Connect to the MongoDB database\n    MongoDBConnection.Connect(\"mongodb://localhost:27017/\", \"Tourney\")\n}\n\nfunc main() {\n    // Find all tourneys\n    document := mongoose.Find(\"users\")\n    \n    // Populate host information\n    fmt.Println(mongoose.PopulateAll(\"followers\", \"users\", document))\n}\n```\n## Contributing\nContributions are welcome! Please feel free to submit a Pull Request or open an Issue if you find bugs or have suggestions for improvements.\n\n## License\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Acknowledgements\n* Inspired by the Mongoose library for Node.js.\n* Thanks to the MongoDB community for their support and resources.\n\n## Changes required\n\n\u003e -Add populate funcionality (This has been done but this is not very efficient and is not exactly like mongoose maybe someday, for now maybe use it or just nested Find functions)\n\n\u003e -Struct funcionalty idk atp\n\n\u003e ~~-Few more functions like findoneandupdate, findonebyid etc~~\n\n\u003e -IDK\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyajatkaul%2Fgo-mongoose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyajatkaul%2Fgo-mongoose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyajatkaul%2Fgo-mongoose/lists"}