-
Notifications
You must be signed in to change notification settings - Fork 5
Working with Hashes
topofocus edited this page May 30, 2019
·
5 revisions
Hashes are created schemaless just by assigning a Hash to a database-property. Any modification returns the modified hash.
Alternatively they can be defined explicitly
> TestModel.create_property :ll, type: :set
# or
> TestModel.create_property :ll, type: :link_set,
linked_class: Contracts> the_record = TestModel.create ll: { tus: 6, tux: 9, zottel: 'rt'}
> the_record.to_human
<TestModel: ll : {:tus=>6, :tux=>9, :zottel=>"rt"}>> the_record.ll[:tux] # => 6
> the_record.ll.slice /tu/ # => {:tus=>6, :tux=>9} > the_record.ll.merge(zt: 7, bla: [8,9,10] ) # returns the modified hash
> the_record.ll[:zt] = 7 # returns the assigned value
INFO->update #25:0 set ll.zt = 7 return after @this
=> {:tus=>6, :tux=>9, :zottel=>"rt", :zt=>7, bla: [8,9,10] } > the_record.ll[:zt] = 'uz'
INFO->update #25:0 set ll.zt = 'uz' return after @this
<TestModel: ll : {:tus=>6, :tux=>9, :zottel=>"rt", :zt=>"uz"}>> the_record.ll.remove :zottel
INFO->update #25:0 remove ll.zottel return after @this
<TestModel: ll : {:tus=>6, :tux=>9, :zt=>"uz"}>Overview
Data Management
- Joining Tables, embedded Lists
- Links and Link Lists
- Relations
- Bidirectional Connections
- Working with Hashes
Public API
- Database
- Model CRUD
Misc