mongous 0.1.4 → 0.2.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 +156 -37
- data/README.ja.adoc +155 -36
- data/lib/mongous/document.rb +66 -31
- data/lib/mongous/extention.rb +59 -46
- data/lib/mongous/filter.rb +82 -60
- data/lib/mongous/version.rb +1 -1
- data/sample/connect_auto_2.rb +2 -1
- data/sample/connect_default_2.rb +2 -1
- data/sample/connect_environ_2.rb +2 -1
- data/sample/connect_loadfile_2.rb +2 -1
- data/sample/declare_compact_1.rb +4 -3
- data/sample/declare_label_1.rb +5 -3
- data/sample/declare_ndex_1.rb +5 -3
- data/sample/declare_ndex_2.rb +5 -3
- data/sample/declare_strict_1.rb +14 -10
- data/sample/declare_strict_2.rb +5 -3
- data/sample/{multi_docs_1.rb → multi_collection_1.rb} +0 -0
- data/sample/multi_collection_2.rb +63 -0
- data/sample/query_basic_1.rb +3 -1
- data/sample/query_basic_2.rb +5 -3
- data/sample/query_basic_3.rb +2 -3
- data/sample/query_basic_4.rb +3 -4
- data/sample/query_basic_5.rb +2 -3
- data/sample/query_detail_1.rb +1 -0
- data/sample/query_detail_2.rb +1 -0
- data/sample/query_detail_3.rb +5 -3
- data/sample/{query_basic_6.rb → query_filter_1.rb} +8 -5
- data/sample/query_filter_2.rb +50 -0
- data/sample/query_find_1.rb +31 -0
- data/sample/query_projection_1.rb +5 -8
- data/sample/query_skip_limit_1.rb +47 -0
- data/sample/query_skip_limit_2.rb +49 -0
- data/sample/query_sort_order_1.rb +46 -0
- data/sample/save_basic_1.rb +1 -2
- data/sample/save_basic_2.rb +1 -2
- data/sample/save_basic_3.rb +1 -2
- data/sample/save_detail_1.rb +7 -4
- data/sample/save_detail_2.rb +7 -4
- data/sample/save_detail_3.rb +10 -7
- data/sample/save_verify_1.rb +7 -4
- data/sample/save_verify_3.rb +1 -1
- data/sample/save_verify_5.rb +3 -3
- data/sample/save_verify_6.rb +3 -3
- data/sample/save_verify_7.rb +23 -0
- data/sample/update_basic_1.rb +13 -0
- data/sample/zap_basic_2.rb +2 -2
- metadata +12 -11
- data/sample/multi_docs_2.rb +0 -58
- data/sample/query_limit_1.rb +0 -44
- data/sample/query_order_1.rb +0 -49
- data/sample/query_raw_1.rb +0 -33
- data/sample/template_article.rb +0 -5
- data/sample/template_person.rb +0 -12
- data/sample/zap_basic_3.rb +0 -11
data/sample/zap_basic_2.rb
CHANGED
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
|
4
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|
@@ -90,21 +90,23 @@ files:
|
|
90
90
|
- sample/declare_ndex_2.rb
|
91
91
|
- sample/declare_strict_1.rb
|
92
92
|
- sample/declare_strict_2.rb
|
93
|
-
- sample/
|
94
|
-
- sample/
|
93
|
+
- sample/multi_collection_1.rb
|
94
|
+
- sample/multi_collection_2.rb
|
95
95
|
- sample/query_basic_1.rb
|
96
96
|
- sample/query_basic_2.rb
|
97
97
|
- sample/query_basic_3.rb
|
98
98
|
- sample/query_basic_4.rb
|
99
99
|
- sample/query_basic_5.rb
|
100
|
-
- sample/query_basic_6.rb
|
101
100
|
- sample/query_detail_1.rb
|
102
101
|
- sample/query_detail_2.rb
|
103
102
|
- sample/query_detail_3.rb
|
104
|
-
- sample/
|
105
|
-
- sample/
|
103
|
+
- sample/query_filter_1.rb
|
104
|
+
- sample/query_filter_2.rb
|
105
|
+
- sample/query_find_1.rb
|
106
106
|
- sample/query_projection_1.rb
|
107
|
-
- sample/
|
107
|
+
- sample/query_skip_limit_1.rb
|
108
|
+
- sample/query_skip_limit_2.rb
|
109
|
+
- sample/query_sort_order_1.rb
|
108
110
|
- sample/save_basic_1.rb
|
109
111
|
- sample/save_basic_2.rb
|
110
112
|
- sample/save_basic_3.rb
|
@@ -117,11 +119,10 @@ files:
|
|
117
119
|
- sample/save_verify_4.rb
|
118
120
|
- sample/save_verify_5.rb
|
119
121
|
- sample/save_verify_6.rb
|
120
|
-
- sample/
|
121
|
-
- sample/
|
122
|
+
- sample/save_verify_7.rb
|
123
|
+
- sample/update_basic_1.rb
|
122
124
|
- sample/zap_basic_1.rb
|
123
125
|
- sample/zap_basic_2.rb
|
124
|
-
- sample/zap_basic_3.rb
|
125
126
|
homepage: https://github.com/arimay/mongous
|
126
127
|
licenses:
|
127
128
|
- MIT
|
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_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
|
-
|
data/sample/query_raw_1.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
|
2
|
-
require "mongous"
|
3
|
-
|
4
|
-
Mongous.connect!
|
5
|
-
|
6
|
-
class Book
|
7
|
-
include Mongous::Document
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
book = Book.collection.find.first
|
12
|
-
p book
|
13
|
-
puts
|
14
|
-
|
15
|
-
Book.collection.find.each do |book|
|
16
|
-
p book
|
17
|
-
end
|
18
|
-
puts
|
19
|
-
|
20
|
-
Book.collection.find( title: /title/ ).each do |book|
|
21
|
-
p book
|
22
|
-
end
|
23
|
-
puts
|
24
|
-
|
25
|
-
Book.collection.find( {}, { projection: {_id: 0, title: 1, author: 1} } ).each do |book|
|
26
|
-
p book
|
27
|
-
end
|
28
|
-
puts
|
29
|
-
|
30
|
-
Book.collection.find( {title: /title/}, { projection: {_id: 0, title: 1, author: 1} } ).each do |book|
|
31
|
-
p book
|
32
|
-
end
|
33
|
-
|
data/sample/template_article.rb
DELETED
data/sample/template_person.rb
DELETED