Skip to content

Store and efficiently retrieve deep ruby hash into postgresql table with hstore field

License

Notifications You must be signed in to change notification settings

niquola/hstored_document

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HstoredDocument

  • Allow store/retrieve deep ruby hash into postgresql table using hstore field.
  • Allow efficient search and indexing by this fields

Installation

Add this line to your application's Gemfile:

gem 'hstored_document'

And then execute:

$ bundle

Or install it yourself as:

$ gem install hstored_document

Usage

create table mydocs (id uuid, attributes hstore);

class MyDocStorage < HstoredDocument
end

id = UUID.generate
doc = {id: id, prop1: 'val1', prop2: [1, 2, 3], prop3: [{nprop: 'nval'}]}

store = MyDocStorage

store.store(doc)
store.find(id).should == doc

store.where('doc.prop2' => 3, prop1: 'val1')
store.where('doc.prop3.nprop' => 'nval')

store.store(doc.merge(propr1: 'changed1'))
store.find(id)[:prop1].should == 'changed1'
store.delete(id)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Store and efficiently retrieve deep ruby hash into postgresql table with hstore field

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages