Models: added basic layout

master
E. Almqvist 3 years ago
parent 0357d4f4af
commit ef8f154026
  1. 6
      src/db_init.rb
  2. 37
      src/db_models.rb

@ -3,7 +3,11 @@ require_relative "db_models.rb"
LOAD_MODELS = [
User,
Role,
User_Role_relation
User_Role_relation,
Auction,
Auction_Category_relation,
Category,
Image
]
def db_init

@ -1,4 +1,4 @@
# User table model
# User model
class User < EntityModel
attr_reader :email, :name, :bio_text, :balance, :avatar_url, :pw_hash, :reputation
@ -127,7 +127,7 @@ class User < EntityModel
end
end
# Role model
class Role < EntityModel
attr_reader :name, :color, :flags
def initialize(data)
@ -172,12 +172,45 @@ class User_Role_relation < EntityModel
end
# Auction model
class Auction < EntityModel
attr_reader :user_id, :title, :description, :init_price, :start_time, :end_time
def initialize(data)
super data
@user_id = data["user_id"]
@title = data["title"]
@description = data["description"]
@init_price = data["init_price"]
@start_time = data["start_time"]
@end_time = data["end_time"]
end
end
class Category < EntityModel
attr_reader :name, :color
def initialize(data)
super data
@name = data["name"]
@color = data["color"]
end
end
class Image < EntityModel
attr_reader :auction_id, :image_order, :url
def initialize(data)
super data
@auction_id = data["auction_id"]
@image_order = data["image_order"]
@url = data["url"]
end
end
class Auction_Category_relation < EntityModel
attr_reader :auction_id, :category_id
def initialize(data)
super data
@auction_id = data["auction_id"]
@category_id = data["category_id"]
end
end

Loading…
Cancel
Save