README.md in jsonb_accessor-1.0.0.beta.5 vs README.md in jsonb_accessor-1.0.0.beta.6

- old
+ new

@@ -27,11 +27,11 @@ ## Installation Add this line to your application's `Gemfile`: ```ruby -gem "jsonb_accessor", "1.0.0.beta.5" +gem "jsonb_accessor", "1.0.0.beta.6" ``` And then execute: $ bundle install @@ -139,10 +139,18 @@ ```ruby Product.all.data_where(reviewed_at: { before: Time.current.beginning_of_week, after: 4.weeks.ago }) ``` +If you want to search for records within a certain time, date, or number range, just pass in the range (Note: this is just shorthand for the above mentioned `before`/`after`/`less_than`/`less_than_or_equal_to`/`greater_than_or_equal_to`/etc options). + +```ruby +Product.all.data_where(price: 10..20) +Product.all.data_where(price: 10...20) +Product.all.data_where(reviewed_at: Time.current..3.days.from_now) +``` + This scope is a convenient wrapper around the `jsonb_where` `scope` that saves you from having to convert the given keys to the store keys and from specifying the column. ### `jsonb_where` Works just like the [`scope` above](#scopes) except that it does not convert the given keys to store keys and you must specify the column name. For example: @@ -160,9 +168,30 @@ 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). ```ruby Product.all.jsonb_where_not(:data, reviewed_at: { before: Time.current }, p: { greater_than: 5 }) +``` + +### `<jsonb_attribute>_order` + +Orders your query according to values in the Jsonb Accessor fields similar to ActiveRecord's `order`. + +```ruby +Product.all.data_order(:price) +Product.all.data_order(:price, :reviewed_at) +Product.all.data_order(:price, reviewed_at: :desc) +``` + +It will convert your given keys into store keys if necessary. + +### `jsonb_order` + +Allows you to order by a Jsonb Accessor field. + +```ruby +Product.all.jsonb_order(:data, :price, :asc) +Product.all.jsonb_order(:data, :price, :desc) ``` ### `jsonb_contains` Returns all records that contain the given JSON paths.