{"id":13878421,"url":"https://github.com/monade/acts_as_nosql","last_synced_at":"2025-11-11T19:30:47.836Z","repository":{"id":38341288,"uuid":"506547596","full_name":"monade/acts_as_nosql","owner":"monade","description":"Allows to treat JSON fields of postgres and mysql as real fields","archived":false,"fork":false,"pushed_at":"2025-03-12T22:21:21.000Z","size":29,"stargazers_count":35,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-25T13:04:13.141Z","etag":null,"topics":["activerecord","gem","json-fields","rails","ruby","sql"],"latest_commit_sha":null,"homepage":"https://monade.io","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/monade.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-06-23T07:55:36.000Z","updated_at":"2025-03-12T22:20:42.000Z","dependencies_parsed_at":"2025-03-11T16:21:16.647Z","dependency_job_id":"7a93db14-4b7a-40c4-a2fa-3fcaa1680ea6","html_url":"https://github.com/monade/acts_as_nosql","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Facts_as_nosql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Facts_as_nosql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Facts_as_nosql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Facts_as_nosql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monade","download_url":"https://codeload.github.com/monade/acts_as_nosql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251840143,"owners_count":21652287,"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":["activerecord","gem","json-fields","rails","ruby","sql"],"created_at":"2024-08-06T08:01:49.114Z","updated_at":"2025-11-11T19:30:42.803Z","avatar_url":"https://github.com/monade.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"![Tests](https://github.com/monade/acts_as_nosql/actions/workflows/test.yml/badge.svg)\n[![Gem Version](https://badge.fury.io/rb/acts_as_nosql.svg)](https://badge.fury.io/rb/acts_as_nosql)\n\n# acts_as_nosql\n\nThis gem allows to handle JSON and JSONB fields as if they are proper database columns, handling default values, type casting and simplifying validation.\n\n## Installation\n\nAdd the gem to your Gemfile\n\n```ruby\n  gem 'acts_as_nosql'\n```\n\n## Example usage\n\n```ruby\nclass User \u003c ApplicationRecord\n  acts_as_nosql field_name: :data\n\n  # You can define multiple attributes at once with the same type\n  nosql_attrs :first_name, :last_name, type: :String\n  # You can set the default value\n  nosql_attr :age, type: :Integer, default: 0\n  # You can also pass a :path attribute\n  # This is used to decide how to write the attribute as a nested object\n  # In this example, `google_oauth_token` will be written in the JSON object as:\n  # `\"oauth\" =\u003e { \"google_token\" =\u003e __VALUE__ }`\n  nosql_attr :google_oauth_token, type: :String, path: [:oauth, :google_token]\n\n  # You can run standard ActiveRecord validations on these fields\n  validates :first_name, :last_name, presence: true\nend\n\nuser = User.new\n# You can use attributes as standard\nuser.first_name = 'John'\nuser.last_name 'Doe'\n# This picks the default value\nuser.age # =\u003e 0\n# This is stored as a nested object\nuser.google_oauth_token = 'xxxxxxx'\nuser.save!\n# All attributes are stored in the `data` column\nuser.data # =\u003e { \"first_name\" =\u003e \"John\", \"last_name\" =\u003e \"Doe\", \"age\" =\u003e 0, \"oauth\" =\u003e { \"google_token\" =\u003e \"xxxxxxx\" }}\n\n# You can also run basic queries:\nUser.where(first_name: 'John').to_sql # =\u003e SELECT \"users\".* FROM \"users\" WHERE \"users\".\"data\"-\u003e\u003e\"first_name\" = 'John'\n```\n\n## TODO\n* Complex querying (`group`, `pluck`, etc...)\n* Issue the arrays mutation bug\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\nAbout Monade\n----------------\n\n![monade](https://monade.io/wp-content/uploads/2023/02/logo-monade.svg)\n\nactive_queryable is maintained by [mònade srl](https://monade.io).\n\nWe \u003c3 open source software. [Contact us](https://monade.io) for your next project!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonade%2Facts_as_nosql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonade%2Facts_as_nosql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonade%2Facts_as_nosql/lists"}