Skip to content

Instantly share code, notes, and snippets.

@belguzmani
Last active August 29, 2015 14:19
Show Gist options
  • Save belguzmani/4a9d4b2038042cd2afc6 to your computer and use it in GitHub Desktop.
Save belguzmani/4a9d4b2038042cd2afc6 to your computer and use it in GitHub Desktop.
Daily Events
class Person
include Mongoid::Document
field :email, type: String
field :month, type: Date
field :monthly_total, type: Hash, default: {:email_open => 0, :email_click => 0, :page_view => 0}
has_many :monthly_events
end
class MonthlyEvent
include Mongoid::Document
field :name, type: String
belongs_to :person
embeds_many :daily_events # this would only contain until 31 documents
end
class DailyEvents
include Mongoid::Document
field :day
field :email_open, type: Integer
field :email_click, type: Integer
field :page_view, type: Integer
embedded_in :monthly_event
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment