diff --git a/CHANGES.md b/CHANGES.md index 1668dbd..abedaab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ ## NEXT +### Added + +* Include AttrJson::Record::QueryScopes in Kithe::Model https://github.com/sciencehistory/kithe/pull/120 + ## 2.1.0 ### Added diff --git a/app/models/kithe/model.rb b/app/models/kithe/model.rb index b9b56a8..c53aefb 100644 --- a/app/models/kithe/model.rb +++ b/app/models/kithe/model.rb @@ -7,6 +7,7 @@ class Kithe::Model < ActiveRecord::Base include AttrJson::Record include AttrJson::NestedAttributes + include AttrJson::Record::QueryScopes include AttrJson::Record::Dirty include Kithe::Indexable diff --git a/guides/modelling.md b/guides/modelling.md index 7ff7065..ff4bdf7 100644 --- a/guides/modelling.md +++ b/guides/modelling.md @@ -110,6 +110,10 @@ Note that you can provide validations on your compound models. Kithe provides so See the [attr_json](https://github.com/jrochkind/attr_json) gem for more documentation on definining metadata with attr_json. +Kithe::Model includes AttrJson querying methods, so for instance: + + Work.jsonb_contains("author.first" => "John") + ### Race conditions and optimistic locking One down-side of storing all attributes serialized in a json hash, is that every save to db with Rails will overwrite the entire json_attributes column. If you have two processes/threads whose execution overlaps, one trying to update (eg) a "publisher" attribute and the other a "language" attribute -- one of the updates could be lost.