mongoid.rb
1.39 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Mongoid.logger = $logger
Mongo::Logger.logger = $logger if defined?(Mongo::Logger)
Mongoid.configure do |config|
config.connect_to "searchkick_test", server_selection_timeout: 1
end
class Product
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :store_id, type: Integer
field :in_stock, type: Boolean
field :backordered, type: Boolean
field :orders_count, type: Integer
field :found_rate, type: BigDecimal
field :price, type: Integer
field :color
field :latitude, type: BigDecimal
field :longitude, type: BigDecimal
field :description
field :alt_description
end
class Store
include Mongoid::Document
has_many :products
field :name
end
class Region
include Mongoid::Document
field :name
field :text
end
class Speaker
include Mongoid::Document
field :name
end
class Animal
include Mongoid::Document
field :name
end
class Dog < Animal
end
class Cat < Animal
end
class Sku
include Mongoid::Document
field :name
end
class Song
include Mongoid::Document
field :name
end
class Band
include Mongoid::Document
field :name
field :active, type: Mongoid::Boolean
default_scope -> { where(active: true).order(name: 1) }
end
class Artist
include Mongoid::Document
field :name
field :active, type: Mongoid::Boolean
field :should_index, type: Mongoid::Boolean
default_scope -> { where(active: true).order(name: 1) }
end