forked from mongodb/mongoid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.rb
63 lines (46 loc) · 1.17 KB
/
models.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Person
include Mongoid::Document
field :birth_date, :type => Date
field :title, :type => String
embeds_one :name, :validate => false
embeds_many :addresses, :validate => false
has_many :posts, :validate => false
has_one :game, :validate => false
has_and_belongs_to_many :preferences, :validate => false
index "preference_ids"
end
class Name
include Mongoid::Document
field :given, :type => String
field :family, :type => String
field :middle, :type => String
embedded_in :person
end
class Address
include Mongoid::Document
field :street, :type => String
field :city, :type => String
field :state, :type => String
field :post_code, :type => String
field :address_type, :type => String
embedded_in :person
end
class Post
include Mongoid::Document
field :title, :type => String
field :content, :type => String
belongs_to :person
index "person_id"
end
class Game
include Mongoid::Document
field :name, :type => String
belongs_to :person
index "person_id"
end
class Preference
include Mongoid::Document
field :name, :type => String
has_and_belongs_to_many :people, :validate => false
index "person_ids"
end