mongous 0.1.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +296 -46
  3. data/README.ja.adoc +297 -47
  4. data/lib/mongous/base.rb +35 -2
  5. data/lib/mongous/document.rb +75 -32
  6. data/lib/mongous/extention.rb +72 -57
  7. data/lib/mongous/filter.rb +273 -208
  8. data/lib/mongous/version.rb +1 -1
  9. data/mongous.gemspec +1 -1
  10. data/sample/connect_auto_0.rb +9 -0
  11. data/sample/connect_auto_2.rb +2 -1
  12. data/sample/connect_default_2.rb +2 -1
  13. data/sample/connect_environ_2.rb +2 -1
  14. data/sample/connect_loadfile_2.rb +2 -1
  15. data/sample/declare_compact_1.rb +7 -7
  16. data/sample/declare_label_1.rb +10 -6
  17. data/sample/declare_ndex_1.rb +9 -5
  18. data/sample/declare_ndex_2.rb +10 -6
  19. data/sample/declare_strict_1.rb +14 -10
  20. data/sample/declare_strict_2.rb +5 -3
  21. data/sample/{multi_docs_1.rb → multi_collection_1.rb} +0 -0
  22. data/sample/multi_collection_2.rb +63 -0
  23. data/sample/multi_collection_3.rb +26 -0
  24. data/sample/query_basic_1.rb +3 -1
  25. data/sample/query_basic_2.rb +5 -3
  26. data/sample/query_basic_3.rb +2 -3
  27. data/sample/query_basic_4.rb +3 -4
  28. data/sample/query_basic_5.rb +2 -3
  29. data/sample/query_detail_1.rb +3 -1
  30. data/sample/query_detail_2.rb +3 -1
  31. data/sample/query_detail_3.rb +5 -3
  32. data/sample/{query_basic_6.rb → query_filter_1.rb} +7 -4
  33. data/sample/query_filter_2.rb +50 -0
  34. data/sample/{query_super_1.rb → query_find_1.rb} +0 -1
  35. data/sample/query_select_1.rb +51 -0
  36. data/sample/query_skip_limit_1.rb +47 -0
  37. data/sample/query_skip_limit_2.rb +49 -0
  38. data/sample/query_sort_order_1.rb +46 -0
  39. data/sample/save_basic_1.rb +1 -2
  40. data/sample/save_basic_2.rb +1 -2
  41. data/sample/save_basic_3.rb +1 -2
  42. data/sample/save_detail_1.rb +7 -4
  43. data/sample/save_detail_2.rb +7 -4
  44. data/sample/save_detail_3.rb +11 -8
  45. data/sample/save_verify_1.rb +7 -4
  46. data/sample/save_verify_3.rb +1 -1
  47. data/sample/save_verify_5.rb +3 -3
  48. data/sample/save_verify_6.rb +3 -3
  49. data/sample/save_verify_7.rb +23 -0
  50. data/sample/update_basic_1.rb +13 -0
  51. data/sample/zap_basic_2.rb +2 -2
  52. data/sample/zap_basic_3.rb +2 -2
  53. data/sample/zbenchmark_search_1.rb +110 -0
  54. data/sample/zbenchmark_search_2.rb +110 -0
  55. data/sample/zbenchmark_search_3.rb +90 -0
  56. metadata +19 -12
  57. data/sample/multi_docs_2.rb +0 -58
  58. data/sample/query_limit_1.rb +0 -44
  59. data/sample/query_order_1.rb +0 -49
  60. data/sample/query_projection_1.rb +0 -44
  61. data/sample/template_article.rb +0 -5
  62. data/sample/template_person.rb +0 -12
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - arimay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-04 00:00:00.000000000 Z
11
+ date: 2020-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: " Yet another lightweight mongo wrapper library. "
55
+ description: " Yet another mongo wrapper library. "
56
56
  email:
57
57
  - arima.yasuhiro@gmail.com
58
58
  executables: []
@@ -75,6 +75,7 @@ files:
75
75
  - lib/mongous/filter.rb
76
76
  - lib/mongous/version.rb
77
77
  - mongous.gemspec
78
+ - sample/connect_auto_0.rb
78
79
  - sample/connect_auto_1.rb
79
80
  - sample/connect_auto_2.rb
80
81
  - sample/connect_default_1.rb
@@ -90,21 +91,24 @@ files:
90
91
  - sample/declare_ndex_2.rb
91
92
  - sample/declare_strict_1.rb
92
93
  - sample/declare_strict_2.rb
93
- - sample/multi_docs_1.rb
94
- - sample/multi_docs_2.rb
94
+ - sample/multi_collection_1.rb
95
+ - sample/multi_collection_2.rb
96
+ - sample/multi_collection_3.rb
95
97
  - sample/query_basic_1.rb
96
98
  - sample/query_basic_2.rb
97
99
  - sample/query_basic_3.rb
98
100
  - sample/query_basic_4.rb
99
101
  - sample/query_basic_5.rb
100
- - sample/query_basic_6.rb
101
102
  - sample/query_detail_1.rb
102
103
  - sample/query_detail_2.rb
103
104
  - sample/query_detail_3.rb
104
- - sample/query_limit_1.rb
105
- - sample/query_order_1.rb
106
- - sample/query_projection_1.rb
107
- - sample/query_super_1.rb
105
+ - sample/query_filter_1.rb
106
+ - sample/query_filter_2.rb
107
+ - sample/query_find_1.rb
108
+ - sample/query_select_1.rb
109
+ - sample/query_skip_limit_1.rb
110
+ - sample/query_skip_limit_2.rb
111
+ - sample/query_sort_order_1.rb
108
112
  - sample/save_basic_1.rb
109
113
  - sample/save_basic_2.rb
110
114
  - sample/save_basic_3.rb
@@ -117,11 +121,14 @@ files:
117
121
  - sample/save_verify_4.rb
118
122
  - sample/save_verify_5.rb
119
123
  - sample/save_verify_6.rb
120
- - sample/template_article.rb
121
- - sample/template_person.rb
124
+ - sample/save_verify_7.rb
125
+ - sample/update_basic_1.rb
122
126
  - sample/zap_basic_1.rb
123
127
  - sample/zap_basic_2.rb
124
128
  - sample/zap_basic_3.rb
129
+ - sample/zbenchmark_search_1.rb
130
+ - sample/zbenchmark_search_2.rb
131
+ - sample/zbenchmark_search_3.rb
125
132
  homepage: https://github.com/arimay/mongous
126
133
  licenses:
127
134
  - MIT
@@ -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
-
@@ -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
-
@@ -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
-
@@ -1,5 +0,0 @@
1
-
2
- class Article
3
- include Mongous::Document
4
- end
5
-
@@ -1,12 +0,0 @@
1
-
2
- class Person
3
- include Mongous::Document
4
-
5
- field :fullname
6
- field :username
7
- field :age, Integer
8
- field :created_at, Date, &proc{ Date.today }
9
-
10
- verify :strict
11
- end
12
-