Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include AttrJson::Record::QueryScopes in Kithe::Model #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## NEXT

### Added

* Include AttrJson::Record::QueryScopes in Kithe::Model https://github.com/sciencehistory/kithe/pull/120

## 2.1.0

### Added
Expand Down
1 change: 1 addition & 0 deletions app/models/kithe/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions guides/modelling.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down