Created
June 7, 2015 17:27
-
-
Save g3d/446b1b2fb185ba387546 to your computer and use it in GitHub Desktop.
lotus uuid example
This file contains 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
class Category | |
include Lotus::Entity | |
# id is implicit | |
attributes :name, :slug, :created_at, :updated_at | |
end |
This file contains 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
class CategoryRepository | |
include Lotus::Repository | |
end |
This file contains 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
mapping do | |
collection :categories do | |
entity Category | |
repository CategoryRepository | |
attribute :id, String | |
attribute :name, String | |
attribute :slug, String | |
attribute :created_at, DateTime | |
attribute :updated_at, DateTime | |
end | |
end |
This file contains 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
Sequel.migration do | |
change do | |
create_table :categories do | |
uuid :id, null: false, default: Sequel.function(:uuid_generate_v4), primary_key: true | |
String :slug, null: false | |
String :name | |
Time :created_at, null: false, default: 'now()' | |
Time :updated_at, null: false, default: 'now()' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment