mongous 0.1.8 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +286 -48
- data/README.ja.adoc +288 -50
- data/lib/mongous/base.rb +45 -2
- data/lib/mongous/document.rb +75 -32
- data/lib/mongous/extention.rb +74 -55
- data/lib/mongous/filter.rb +316 -233
- data/lib/mongous/version.rb +1 -1
- data/mongous.gemspec +1 -1
- data/sample/connect_auto_0.rb +9 -0
- data/sample/declare_compact_1.rb +7 -9
- data/sample/declare_compact_2.rb +38 -0
- data/sample/declare_label_1.rb +10 -8
- data/sample/declare_ndex_1.rb +9 -7
- data/sample/declare_ndex_2.rb +10 -8
- data/sample/declare_strict_1.rb +14 -12
- data/sample/declare_strict_2.rb +5 -5
- data/sample/{multi_docs_1.rb → multi_collection_1.rb} +0 -2
- data/sample/multi_collection_2.rb +61 -0
- data/sample/multi_collection_3.rb +24 -0
- data/sample/query_basic_1.rb +8 -3
- data/sample/query_basic_2.rb +11 -6
- data/sample/query_basic_3.rb +2 -5
- data/sample/query_basic_4.rb +3 -6
- data/sample/query_basic_5.rb +2 -5
- data/sample/query_basic_6.rb +35 -22
- data/sample/query_detail_1.rb +3 -3
- data/sample/query_detail_2.rb +3 -3
- data/sample/query_detail_3.rb +5 -5
- data/sample/query_filter_1.rb +44 -0
- data/sample/query_filter_2.rb +48 -0
- data/sample/{query_super_1.rb → query_find_1.rb} +6 -6
- data/sample/query_select_1.rb +54 -0
- data/sample/query_skip_limit_1.rb +48 -0
- data/sample/query_skip_limit_2.rb +58 -0
- data/sample/query_sort_1.rb +43 -0
- data/sample/save_basic_1.rb +2 -7
- data/sample/save_basic_2.rb +2 -7
- data/sample/save_basic_3.rb +2 -7
- data/sample/save_detail_1.rb +7 -6
- data/sample/save_detail_2.rb +7 -6
- data/sample/save_detail_3.rb +11 -10
- data/sample/save_verify_1.rb +7 -6
- data/sample/save_verify_2.rb +0 -2
- data/sample/save_verify_3.rb +1 -3
- data/sample/save_verify_4.rb +0 -2
- data/sample/save_verify_5.rb +3 -5
- data/sample/save_verify_6.rb +3 -5
- data/sample/save_verify_7.rb +21 -0
- data/sample/update_basic_1.rb +9 -0
- data/sample/zap_basic_1.rb +1 -5
- data/sample/zap_basic_2.rb +2 -6
- data/sample/zap_basic_3.rb +2 -6
- data/sample/zbenchmark_search_1.rb +114 -0
- data/sample/zbenchmark_search_2.rb +114 -0
- data/sample/zbenchmark_search_3.rb +88 -0
- metadata +20 -12
- data/sample/multi_docs_2.rb +0 -58
- data/sample/query_basic_7.rb +0 -38
- data/sample/query_limit_1.rb +0 -44
- data/sample/query_order_1.rb +0 -49
- data/sample/query_projection_1.rb +0 -44
- data/sample/template_article.rb +0 -5
- data/sample/template_person.rb +0 -12
data/sample/multi_docs_2.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
|
2
|
-
require "mongous"
|
3
|
-
|
4
|
-
Mongous.connect!
|
5
|
-
|
6
|
-
class Book1
|
7
|
-
include Mongous::Document
|
8
|
-
end
|
9
|
-
|
10
|
-
class Book2
|
11
|
-
include Mongous::Document
|
12
|
-
|
13
|
-
field :title
|
14
|
-
field :publisher
|
15
|
-
field :author
|
16
|
-
field :style
|
17
|
-
field :price
|
18
|
-
field :page
|
19
|
-
field :publish_at
|
20
|
-
field :isbn
|
21
|
-
field :lang
|
22
|
-
|
23
|
-
verify :strict
|
24
|
-
end
|
25
|
-
|
26
|
-
class Book3
|
27
|
-
include Mongous::Document
|
28
|
-
|
29
|
-
field :title, :must
|
30
|
-
field :author,
|
31
|
-
field :publisher,
|
32
|
-
field :price, Integer, (0..1_000_000)
|
33
|
-
field :page, Integer, proc{ page > 0 }
|
34
|
-
field :publish_at, Date, &proc{ Date.today }
|
35
|
-
field :isbn, proc{ isbn? }
|
36
|
-
field :lang, &proc{ "ja" }
|
37
|
-
|
38
|
-
verify :strict
|
39
|
-
verify { having?( title ) }
|
40
|
-
verify do
|
41
|
-
having?( author ) | having?( publisher )
|
42
|
-
end
|
43
|
-
|
44
|
-
def isbn?
|
45
|
-
isbn&.gsub(/[\D]*/, '').size == 13
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
pp Book1.fields
|
51
|
-
puts
|
52
|
-
|
53
|
-
pp Book2.fields
|
54
|
-
puts
|
55
|
-
|
56
|
-
pp Book3.fields
|
57
|
-
puts
|
58
|
-
|
data/sample/query_basic_7.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
|
2
|
-
require "mongous"
|
3
|
-
|
4
|
-
Mongous.connect!
|
5
|
-
|
6
|
-
class Book
|
7
|
-
include Mongous::Document
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
p count = Book.filter.count
|
12
|
-
puts
|
13
|
-
|
14
|
-
p count = Book.filter[0..4].count
|
15
|
-
puts
|
16
|
-
|
17
|
-
p count = Book.filter[0...4].count
|
18
|
-
puts
|
19
|
-
|
20
|
-
p count = Book.filter[0, 4].count
|
21
|
-
puts
|
22
|
-
|
23
|
-
p count = Book.filter[20,10].count
|
24
|
-
puts
|
25
|
-
|
26
|
-
pp books = Book.filter[0, 2].all
|
27
|
-
puts
|
28
|
-
|
29
|
-
filter = Book.filter( title: /title/ )
|
30
|
-
filter[0, 4].each do |book|
|
31
|
-
p book
|
32
|
-
end
|
33
|
-
puts
|
34
|
-
filter[4, 4].each do |book|
|
35
|
-
p book
|
36
|
-
end
|
37
|
-
puts
|
38
|
-
|
data/sample/query_limit_1.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
|
2
|
-
require "mongous"
|
3
|
-
|
4
|
-
Mongous.connect!
|
5
|
-
|
6
|
-
class Item
|
7
|
-
include Mongous::Document
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
(0...10).each do |n|
|
12
|
-
if item = Item.filter( n: n ).first
|
13
|
-
item
|
14
|
-
else
|
15
|
-
Item.create( n: n )
|
16
|
-
end
|
17
|
-
end
|
18
|
-
puts
|
19
|
-
|
20
|
-
Item.each do |item|
|
21
|
-
p item
|
22
|
-
end
|
23
|
-
puts
|
24
|
-
|
25
|
-
Item.filter.skip(2).each do |item|
|
26
|
-
p item
|
27
|
-
end
|
28
|
-
puts
|
29
|
-
|
30
|
-
Item.filter.limit(3).each do |item|
|
31
|
-
p item
|
32
|
-
end
|
33
|
-
puts
|
34
|
-
|
35
|
-
Item.filter.skip(4).limit(5).each do |item|
|
36
|
-
p item
|
37
|
-
end
|
38
|
-
puts
|
39
|
-
|
40
|
-
Item.filter.offset(4).limit(5).each do |item|
|
41
|
-
p item
|
42
|
-
end
|
43
|
-
puts
|
44
|
-
|
data/sample/query_order_1.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
|
2
|
-
require "mongous"
|
3
|
-
|
4
|
-
Mongous.connect!
|
5
|
-
|
6
|
-
class Item
|
7
|
-
include Mongous::Document
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
(0...10).each do |n|
|
12
|
-
if item = Item.filter( n: n ).first
|
13
|
-
item
|
14
|
-
else
|
15
|
-
Item.create( n: n )
|
16
|
-
end
|
17
|
-
end
|
18
|
-
puts
|
19
|
-
|
20
|
-
Item.each do |item|
|
21
|
-
p item
|
22
|
-
end
|
23
|
-
puts
|
24
|
-
|
25
|
-
Item.filter.sort(n: 1).each do |item|
|
26
|
-
p item
|
27
|
-
end
|
28
|
-
puts
|
29
|
-
|
30
|
-
Item.filter.sort(n: -1).each do |item|
|
31
|
-
p item
|
32
|
-
end
|
33
|
-
puts
|
34
|
-
|
35
|
-
Item.filter.order(n: -1).each do |item|
|
36
|
-
p item
|
37
|
-
end
|
38
|
-
puts
|
39
|
-
|
40
|
-
Item.filter( n: (3...8) ).order(n: -1).each do |item|
|
41
|
-
p item
|
42
|
-
end
|
43
|
-
puts
|
44
|
-
|
45
|
-
Item.filter( n: [0,2,4,6,8] ).order(n: -1).each do |item|
|
46
|
-
p item
|
47
|
-
end
|
48
|
-
puts
|
49
|
-
|
@@ -1,44 +0,0 @@
|
|
1
|
-
|
2
|
-
require "mongous"
|
3
|
-
|
4
|
-
Mongous.connect!
|
5
|
-
|
6
|
-
class Label
|
7
|
-
include Mongous::Document
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
(0...10).each do |n|
|
12
|
-
if label = Label.filter( n: n ).first
|
13
|
-
label
|
14
|
-
else
|
15
|
-
Label.create( n: n, tag: [0x40 + n].pack("C") )
|
16
|
-
end
|
17
|
-
end
|
18
|
-
puts
|
19
|
-
|
20
|
-
Label.each do |label|
|
21
|
-
p label
|
22
|
-
end
|
23
|
-
puts
|
24
|
-
|
25
|
-
Label.filter.projection( tag: 1 ).each do |label|
|
26
|
-
p label
|
27
|
-
end
|
28
|
-
puts
|
29
|
-
|
30
|
-
Label.filter.projection( _id: 0, n: 1 ).each do |label|
|
31
|
-
p label
|
32
|
-
end
|
33
|
-
puts
|
34
|
-
|
35
|
-
Label.filter.select( _id: 0, n: 1, tag: 1 ).each do |label|
|
36
|
-
p label
|
37
|
-
end
|
38
|
-
puts
|
39
|
-
|
40
|
-
Label.filter( n: [0,2,4,6,8] ).select( _id: 0, n: 1, tag: 1 ).each do |label|
|
41
|
-
p label
|
42
|
-
end
|
43
|
-
puts
|
44
|
-
|
data/sample/template_article.rb
DELETED