README.md in jsonb_accessor-1.3.0 vs README.md in jsonb_accessor-1.3.1

- old
+ new

@@ -8,19 +8,19 @@ It also adds generic scopes for querying `jsonb` columns. ## Table of Contents -* [Installation](#installation) -* [Usage](#usage) -* [Scopes](#scopes) -* [Single-Table Inheritance](#single-table-inheritance) -* [Dependencies](#dependencies) -* [Validations](#validations) -* [Upgrading](#upgrading) -* [Development](#development) -* [Contributing](#contributing) +- [Installation](#installation) +- [Usage](#usage) +- [Scopes](#scopes) +- [Single-Table Inheritance](#single-table-inheritance) +- [Dependencies](#dependencies) +- [Validations](#validations) +- [Upgrading](#upgrading) +- [Development](#development) +- [Contributing](#contributing) ## Installation Add this line to your application's `Gemfile`: @@ -156,10 +156,11 @@ # instead of Product.all.data_where(reviewed_at: { before: Time.current }, price: { greater_than: 5 }) ``` + This scope makes use of the `jsonb_contains`, `jsonb_number_where`, and `jsonb_time_where` `scope`s. ### `jsonb_where_not` Just the opposite of `jsonb_where`. Note that this will automatically exclude all records that contain `null` in their jsonb column (the `data` column, in the example below). @@ -217,18 +218,18 @@ Product.all.jsonb_number_where(:data, :price_in_cents, :greater_than, 300) ``` It supports: -* `>` -* `>=` -* `greater_than` -* `greater_than_or_equal_to` -* `<` -* `<=` -* `less_than` -* `less_than_or_equal_to` +- `>` +- `>=` +- `greater_than` +- `greater_than_or_equal_to` +- `<` +- `<=` +- `less_than` +- `less_than_or_equal_to` and it is indifferent to strings/symbols. ### `jsonb_number_where_not` @@ -257,13 +258,13 @@ ``` ## Single-Table Inheritance One of the big issues with `ActiveRecord` single-table inheritance (STI) -is sparse columns. Essentially, as sub-types of the original table +is sparse columns. Essentially, as sub-types of the original table diverge further from their parent more columns are left empty in a given -table. Postgres' `jsonb` type provides part of the solution in that +table. Postgres' `jsonb` type provides part of the solution in that the values in an `jsonb` column does not impose a structure - different rows can have different values. We set up our table with an `jsonb` field: @@ -303,11 +304,11 @@ safety_rating: :integer end ``` From here any attributes specific to any sub-class can be stored in the -`jsonb` column avoiding sparse data. Indices can also be created on +`jsonb` column avoiding sparse data. Indices can also be created on individual fields in an `jsonb` column. This approach was originally conceived by Joe Hirn in [this blog post](https://madeintandem.com/blog/2013-3-single-table-inheritance-hstore-lovely-combination/). @@ -324,14 +325,26 @@ See the [upgrade guide](UPGRADE_GUIDE.md). ## Development +### On your local machine + After checking out the repo, run `bin/setup` to install dependencies (make sure postgres is running first). Run `bin/console` for an interactive prompt that will allow you to experiment. `rake` will run Rubocop and the specs. + +### With Docker + +``` +# setup +docker-compose build +docker-compose run ruby rake db:migrate +# run test suite +docker-compose run ruby rake spec +``` ## Contributing 1. [Fork it](https://github.com/madeintandem/jsonb_accessor/fork) 2. Create your feature branch (`git checkout -b my-new-feature`)