https://github.com/reednj/sequel-json_columns
Add json fields to sequel, even if not supported by the engine
https://github.com/reednj/sequel-json_columns
json ruby sequel
Last synced: about 2 months ago
JSON representation
Add json fields to sequel, even if not supported by the engine
- Host: GitHub
- URL: https://github.com/reednj/sequel-json_columns
- Owner: reednj
- License: mit
- Created: 2017-06-21T01:42:08.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-21T03:50:58.000Z (almost 9 years ago)
- Last Synced: 2025-06-06T17:09:41.705Z (about 1 year ago)
- Topics: json, ruby, sequel
- Language: Ruby
- Homepage: https://rubygems.org/gems/sequel-json_columns
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Sequel::Plugins::JsonColumns
This plugin allows using json type columns in sequel, even in mysql where the database doesn't support them.
## Usage
Add the plugin to all models in the following way:
class Sequel::Model
plugin :json_columns
end
Then flag individual columns as containing json data with the `json_column` class method.
class User < Sequel::Model
json_column :metadata
# ...
end
The content of these columns will be automatically parsed as json, so you can access the data as a hash, array etc
user = User.first
user.metadata # => {:name => 'dave', :age => 22}
user.metadata[:age] += 1
user.save_changess
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'sequel-json_columns'
```
Or install it yourself as:
$ gem install sequel-json_columns
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).