{"id":24548171,"url":"https://github.com/flanker/simple_tenant","last_synced_at":"2025-03-16T11:17:38.662Z","repository":{"id":48138543,"uuid":"142561035","full_name":"flanker/simple_tenant","owner":"flanker","description":"A very simple multi-tenant library for ruby with mongodb (based on mongoid).","archived":false,"fork":false,"pushed_at":"2022-07-24T02:22:36.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-26T19:02:42.035Z","etag":null,"topics":["mongoid","mongoid-plugin","multitenancy","ruby","rubygem"],"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/flanker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-27T10:03:15.000Z","updated_at":"2022-07-24T02:22:35.000Z","dependencies_parsed_at":"2022-08-28T04:55:13.125Z","dependency_job_id":null,"html_url":"https://github.com/flanker/simple_tenant","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flanker%2Fsimple_tenant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flanker%2Fsimple_tenant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flanker%2Fsimple_tenant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flanker%2Fsimple_tenant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flanker","download_url":"https://codeload.github.com/flanker/simple_tenant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858058,"owners_count":20359269,"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":["mongoid","mongoid-plugin","multitenancy","ruby","rubygem"],"created_at":"2025-01-22T23:16:16.140Z","updated_at":"2025-03-16T11:17:38.644Z","avatar_url":"https://github.com/flanker.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Tenant\n\n[![Build Status](https://www.travis-ci.com/flanker/simple_tenant.svg?branch=master)](https://www.travis-ci.com/flanker/simple_tenant)\n\nA very simple multi-tenant library for ruby with __mongodb (based on mongoid)__.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'simple_tenant'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install simple_tenant\n\n## Usage\n\nModel definition:\n\n```ruby\n  class TestModel\n    include Mongoid::Document\n    include SimpleTenant::ModelExtensions\n\n    field :name, type: String\n    field :number, type: Integer\n    field :text, type: String\n    field :deleted_at, type: Time\n    field :tenant_id, type: Integer\n\n    tenanted_by :tenant_id\n\n    default_scope { where(deleted_at: nil) }\n  end\n```\n\nand:\n\n```ruby\nTestModel.create name: 'document with tenant', tenant_id: 828\nTestModel.create name: 'document with another tenant', tenant_id: 1113\nTestModel.create name: 'document without tenant'\n\nSimpleTenant.current_tenant = 828\n\nTestModel.count    # =\u003e 1\nTestModel.first.name    # ==\u003e document with tenant\n```\n\nSee more usage example in specs:\n\n1. [SimpleTenant::ModelExtensions](https://github.com/flanker/simple_tenant/blob/master/spec/simple_tenant/model_extensions_spec.rb)\n2. [SimpleTenant::ModelExtensions for relation](https://github.com/flanker/simple_tenant/blob/master/spec/simple_tenant/model_extensions_with_relation_spec.rb)\n3. [SimpleTenant::ModelExtensions for inheritance](https://github.com/flanker/simple_tenant/blob/master/spec/simple_tenant/model_extensions_with_inheritance_spec.rb)\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflanker%2Fsimple_tenant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflanker%2Fsimple_tenant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflanker%2Fsimple_tenant/lists"}