Skip to content

Instantly share code, notes, and snippets.

@g3d
Created June 7, 2015 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g3d/446b1b2fb185ba387546 to your computer and use it in GitHub Desktop.
Save g3d/446b1b2fb185ba387546 to your computer and use it in GitHub Desktop.
lotus uuid example
class Category
include Lotus::Entity
# id is implicit
attributes :name, :slug, :created_at, :updated_at
end
class CategoryRepository
include Lotus::Repository
end
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
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