Last active
December 18, 2015 08:09
-
-
Save TikiTDO/5751906 to your computer and use it in GitHub Desktop.
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
class OrderCoupon | |
include Mongoid::Document | |
field :code, type: String | |
field :discount, type: Integer | |
field :discount_type, type: String # Flat Price, Percentage | |
field :expiration, type: Date | |
belongs_to :order | |
end | |
class ProductCoupon | |
include Mongoid::Document | |
field :code, type: String | |
field :discount, type: Integer | |
field :discount_type, type: String # Flat Price, Percentage | |
field :expiration, type: Date | |
belongs_to :product | |
end | |
class Product | |
include Mongoid::Document | |
field :name, type: String | |
field :description, type: String | |
field :price, type: Integer | |
has_one :categorization | |
has_many :options | |
has_many :product_coupon | |
has_many :cart_items | |
end | |
class Option | |
include Mongoid::Document | |
field :name, type: String | |
field :description, type: String | |
field :price, type: Integer | |
belongs_to :product | |
end | |
class Categorization | |
include Mongoid::Document | |
field :category, type: String | |
field :subcategory, type: String | |
belongs_to :product | |
end | |
class CartItem | |
include Mongoid::Document | |
belongs_to :product | |
belogns_to :cart | |
has_many :cart_item_options | |
end | |
class CartItemOption | |
belongs_to :cart_item | |
# Each cart item option belongs to either an option, or a coupon option | |
belongs_to :option | |
belongs_to :product_coupon | |
end | |
class Cart | |
include Mongoid::Document | |
has_many :cart_items | |
has_one :order | |
belongs_to :user | |
end | |
class Order | |
include Mongoid::Document | |
field :status, type: String | |
field :payment, type: Hash | |
belongs_to :cart | |
belongs_to :order_coupon | |
end | |
class User | |
include Mongoid::Document | |
# User Name | |
field :name, type: String | |
# Auth Data | |
field :password_digest, type: String | |
field :auth_token, type: String | |
has_secure_password | |
has_many :carts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment