Created
February 5, 2017 22:52
-
-
Save zaiste/3768b6febfcd82941ad18b40bad1c6ca to your computer and use it in GitHub Desktop.
Ruby & Datamapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'data_mapper' | |
| require 'dm-pg-types' | |
| DataMapper.setup(:default, 'postgres://localhost/play') | |
| class Person | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :name, String | |
| property :info, HStore | |
| property :decimals, DecimalArray, :scale => 5, :precision => 10 | |
| property :carts, StringArray | |
| end | |
| DataMapper.finalize | |
| DataMapper.auto_upgrade! | |
| p = Person.first(id: '5') | |
| p.decimals = p.decimals.push(2.0) | |
| zoo = p.carts | |
| zoo.delete('pod') | |
| p.carts = zoo | |
| p.save | |
| p p.decimals | |
| p p.carts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment