{"id":19882106,"url":"https://github.com/codeclimate/minidoc","last_synced_at":"2025-05-02T14:31:42.655Z","repository":{"id":12211444,"uuid":"14817892","full_name":"codeclimate/minidoc","owner":"codeclimate","description":"Lightweight MongoDB object document mapper","archived":false,"fork":false,"pushed_at":"2023-08-01T21:13:18.000Z","size":195,"stargazers_count":13,"open_issues_count":0,"forks_count":11,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-08-08T22:16:50.143Z","etag":null,"topics":["opensource"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/codeclimate.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2013-11-30T08:44:52.000Z","updated_at":"2024-04-25T20:21:49.000Z","dependencies_parsed_at":"2024-06-23T04:16:21.406Z","dependency_job_id":null,"html_url":"https://github.com/codeclimate/minidoc","commit_stats":{"total_commits":134,"total_committers":13,"mean_commits":"10.307692307692308","dds":0.6417910447761195,"last_synced_commit":"cf4605f4afab0d4dc06c2010b2b9a40695ce77f5"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeclimate%2Fminidoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeclimate%2Fminidoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeclimate%2Fminidoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeclimate%2Fminidoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeclimate","download_url":"https://codeload.github.com/codeclimate/minidoc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224315110,"owners_count":17290992,"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":["opensource"],"created_at":"2024-11-12T17:16:25.874Z","updated_at":"2024-11-12T17:16:26.427Z","avatar_url":"https://github.com/codeclimate.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/codeclimate/minidoc.svg)](https://travis-ci.org/codeclimate/minidoc)\n[![Gem Version](https://badge.fury.io/rb/minidoc.svg)](http://badge.fury.io/rb/minidoc)\n[![Code Climate](https://codeclimate.com/github/codeclimate/minidoc/badges/gpa.svg)](https://codeclimate.com/github/codeclimate/minidoc)\n[![Test Coverage](https://codeclimate.com/github/codeclimate/minidoc/badges/coverage.svg)](https://codeclimate.com/github/codeclimate/minidoc/coverage)\n\n# Minidoc\n\nMinidoc is an extremely lightweight layer on top of the MongoDB client to\nmake interacting with documents from Ruby more convenient.\n\nWe rely heavily on the MongoDB client, Virtus and ActiveModel to keep\nthings as simple as possible.\n\n## Features\n\n* Interact with Ruby objects instead of hashes\n* Full access to the powerful MongoDB client\n* Thread safe (hopefully)\n* Simple and easily extensible\n* ActiveModel-compatible\n* Validations\n* Timestamp tracking (created_at/updated_at)\n* Very basic associations (for reads)\n* Conversion into immutable value objects\n* Read-only records\n\n## Anti-Features\n\n* Custom query API (just use Mongo)\n* Callbacks (just define a method like save and call super)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"minidoc\"\n```\n\nAnd then execute:\n\n```\n$ bundle\n```\n\nOr install it yourself as:\n\n```\n$ gem install minidoc\n```\n\n## Usage\n\n### Setup\n\n```ruby\nMinidoc.connection = Mongo::Client.new(\"mongodb://localhost\")\nMinidoc.database_name = \"my_great_app_development\"\n```\n\n### Basics\n\n```ruby\nclass User \u003c Minidoc\n  include Minidoc::Timestamps\n\n  attribute :name, String\n  attribute :language, String\n  timestamps!\nend\n\nuser = User.create!(name: \"Bryan\", language: \"Cobol\")\nUser.count # =\u003e 1\n\nuser.language = \"Lisp\"\nuser.save!\n\nuser.set(language: \"Fortran\")\n\nuser.destroy\nUser.count # =\u003e 0\n```\n\n### Validations\n\nJust uses [`ActiveModel::Validations`](http://api.rubyonrails.org/classes/ActiveModel/Validations.html):\n\n```ruby\nclass User \u003c Minidoc\n  attribute :name, String\n\n  validates :name, presence: true\nend\n\nuser = User.new\nuser.valid? # =\u003e false\nuser.name = \"Bryan\"\nuser.valid? # =\u003e true\n```\n\n### Value Objects\n\n```ruby\nbryan = User.create(name: \"Bryan\").as_value\nbryan.name #=\u003e \"Bryan\"\nbryan.name = \"Brian\" #=\u003e NoMethodError\n```\n\n### Associations\n\n```ruby\nclass Drink \u003c Minidoc\n  include Minidoc::Associations\n\n  attribute :name, String\n\n  belongs_to :user\nend\n\nbryan = User.create(name: \"Bryan\")\ndrink = Drink.create(name: \"Paloma\", user: bryan)\ndrink.user == bryan #=\u003e true\n```\n\nAssociations are also exposed as \"bang methods\" which raise a\n`Minidoc::DocumentNotFoundError` if the record pointed to by the foreign key is\nno longer present. (This can be useful in web frameworks where such exceptions\nautomatically result in 404 responses.)\n\n```rb\nuser.destroy\nDrink.find(name: \"Paloma\").user!\n# =\u003e Minidoc::DocumentNotFoundError\n```\n\n### Read-only records\n\n```ruby\nclass DrinkEvents \u003c Minidoc::ReadOnly\n  include Minidoc::Timestamps\n  timestamps!\nend\n\nDrinkEvents.count(created_at: { \"$gt\": 4.days.ago }) #=\u003e 0\nDrinkEvents.create #=\u003e NoMethodError\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/codeclimate/minidoc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\nWhen making a pull request, please update the [changelog](CHANGELOG.md).\n\n## Running the tests locally\n\nWe use Docker! You can run:\n\n```shell\nmake mongodb-test-server\nmake test\n```\n\n## Releasing\n\n* Update the changelog to mark the unreleased changes as part of the new release.\n* Update the version.rb with the new version number\n* Make a pull request with those changes\n* Merge those changes to master\n* Check out and pull down the latest master locally\n* `rake release` which will\n  * tag the latest commit based on version.rb\n  * push to github\n  * push to rubygems\n* Copy the relevant changelog entries into a new [GitHub release](https://github.com/codeclimate/minidoc/releases).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeclimate%2Fminidoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeclimate%2Fminidoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeclimate%2Fminidoc/lists"}