README.md in jsonb_accessor-1.0.0.beta.3 vs README.md in jsonb_accessor-1.0.0.beta.4

- old
+ new

@@ -1,9 +1,11 @@ # JSONb Accessor -Created by [<img src="https://raw.githubusercontent.com/devmynd/jsonb_accessor/master/devmynd-logo.png" alt="DevMynd Logo" />](https://www.devmynd.com/) [![Gem Version](https://badge.fury.io/rb/jsonb_accessor.svg)](http://badge.fury.io/rb/jsonb_accessor) [![Build Status](https://travis-ci.org/devmynd/jsonb_accessor.svg)](https://travis-ci.org/devmynd/jsonb_accessor) <img src="https://raw.githubusercontent.com/devmynd/jsonb_accessor/master/json-bee.png" alt="JSONb Accessor Logo" align="right" /> +Created by &nbsp;&nbsp;&nbsp; [<img src="https://raw.githubusercontent.com/devmynd/jsonb_accessor/master/devmynd-logo.png" alt="DevMynd Logo" />](https://www.devmynd.com/) +[![Gem Version](https://badge.fury.io/rb/jsonb_accessor.svg)](http://badge.fury.io/rb/jsonb_accessor) &nbsp;&nbsp;&nbsp;[![Build Status](https://travis-ci.org/devmynd/jsonb_accessor.svg)](https://travis-ci.org/devmynd/jsonb_accessor) <img src="https://raw.githubusercontent.com/devmynd/jsonb_accessor/master/json-bee.png" alt="JSONb Accessor Logo" align="right" /> + Adds typed `jsonb` backed fields as first class citizens to your `ActiveRecord` models. This gem is similar in spirit to [HstoreAccessor](https://github.com/devmynd/hstore_accessor), but the `jsonb` column in PostgreSQL has a few distinct advantages, mostly around nested documents and support for collections. It also adds generic scopes for querying `jsonb` columns. ## 1.0 Beta @@ -25,11 +27,11 @@ ## Installation Add this line to your application's `Gemfile`: ```ruby -gem "jsonb_accessor", "1.0.0.beta.3" +gem "jsonb_accessor", "1.0.0.beta.4" ``` And then execute: $ bundle install @@ -69,11 +71,11 @@ title: [:string, default: "Untitled"], previous_titles: [:string, array: true, default: []] end ``` -A brief note about defaults: `default` works pretty much as you would expect in practice, but it actually becomes part of a defaults hash that is the `default` value for the jsonb column (in the above example it would be `:data`). +The `default` option works pretty much as you would expect in practice; if no values are set for the attributes, a hash of the specified default values is saved to the jsonb column. You can also pass in a `store_key` option. ```ruby class Product < ActiveRecord::Base @@ -151,9 +153,17 @@ # 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). + +```ruby +Product.all.jsonb_where_not(:data, reviewed_at: { before: Time.current }, p: { greater_than: 5 }) +``` ### `jsonb_contains` Returns all records that contain the given JSON paths.