mongous 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +21 -6
- data/README.ja.adoc +20 -5
- data/lib/mongous/extention.rb +4 -0
- data/lib/mongous/version.rb +1 -1
- data/sample/query_super_1.rb +32 -0
- metadata +2 -2
- data/sample/query_raw_1.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6616ba889ba858cb82f877ba24bb755ec8e205aa9b8c70738864ce855d5ebb52
|
4
|
+
data.tar.gz: d733c6a2bcaeec6725f51f2e7638f8fd9cd99c7decfe568fcf0b80ee98cd3ebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ae43077eadf5806fe60e766050a58dfb926de35ebe50f7af0e2f7a37b3b9675112cdd3a80ca95837c93513b0286154caab863f125b3f33d0e4958ed14b6237a
|
7
|
+
data.tar.gz: 2e21b03862a403e6839ca2c6e569879c06e3c6f3f5e6fb63409ee6799a0257443a8e2c6612bf4a35956aa4cd931f108c2c3640c8a71c8749fa90b8913b7ac98d
|
data/README.adoc
CHANGED
@@ -30,7 +30,7 @@ Or install it yourself as:
|
|
30
30
|
|
31
31
|
== Usage
|
32
32
|
|
33
|
-
=== Simple
|
33
|
+
=== Simple declaration
|
34
34
|
|
35
35
|
[source,ruby]
|
36
36
|
----
|
@@ -91,18 +91,16 @@ book = Book.new( title: "title 2", price: 2000, style: "A5" )
|
|
91
91
|
book.save
|
92
92
|
|
93
93
|
doc = { title: "title 3", price: 3000, style: "A6" }
|
94
|
-
Book.create( doc )
|
94
|
+
Book.create( **doc )
|
95
95
|
----
|
96
96
|
|
97
97
|
=== Search document
|
98
98
|
|
99
99
|
[source,ruby]
|
100
100
|
----
|
101
|
-
books = Book.all
|
102
|
-
pp books
|
101
|
+
pp books = Book.all
|
103
102
|
|
104
|
-
book = Book.filter( title: "title 1" ).first
|
105
|
-
p book
|
103
|
+
p book = Book.filter( title: "title 1" ).first
|
106
104
|
|
107
105
|
books = Book.filter( title: /title/ ).all
|
108
106
|
books.each do |book|
|
@@ -116,6 +114,23 @@ end
|
|
116
114
|
Book.filter( price: (1..2000), style: ["A4","A5"] ).each do |book|
|
117
115
|
p book
|
118
116
|
end
|
117
|
+
|
118
|
+
filter1 = Book.filter( title: /title/ )
|
119
|
+
filter2 = Book.filter( price: (1..2000) )
|
120
|
+
filter3 = Book.filter( style: ["A4","A5"] )
|
121
|
+
Book.not( filter1 ).each do |book|
|
122
|
+
p book
|
123
|
+
end
|
124
|
+
Book.and( filter1, filter2 ).each do |book|
|
125
|
+
p book
|
126
|
+
end
|
127
|
+
Book.or( filter1, filter3 ).each do |book|
|
128
|
+
p book
|
129
|
+
end
|
130
|
+
|
131
|
+
Book.find( {}, { projection: {_id: 0} } ).each do |book|
|
132
|
+
p book
|
133
|
+
end
|
119
134
|
----
|
120
135
|
|
121
136
|
=== Update document
|
data/README.ja.adoc
CHANGED
@@ -91,18 +91,16 @@ book = Book.new( title: "title 2", price: 2000, style: "A5" )
|
|
91
91
|
book.save
|
92
92
|
|
93
93
|
doc = { title: "title 3", price: 3000, style: "A6" }
|
94
|
-
Book.create( doc )
|
94
|
+
Book.create( **doc )
|
95
95
|
----
|
96
96
|
|
97
97
|
=== ドキュメント検索
|
98
98
|
|
99
99
|
[source,ruby]
|
100
100
|
----
|
101
|
-
books = Book.all
|
102
|
-
pp books
|
101
|
+
pp books = Book.all
|
103
102
|
|
104
|
-
book = Book.filter( title: "title 1" ).first
|
105
|
-
p book
|
103
|
+
p book = Book.filter( title: "title 1" ).first
|
106
104
|
|
107
105
|
books = Book.filter( title: /title/ ).all
|
108
106
|
books.each do |book|
|
@@ -116,6 +114,23 @@ end
|
|
116
114
|
Book.filter( price: (1..2000), style: ["A4","A5"] ).each do |book|
|
117
115
|
p book
|
118
116
|
end
|
117
|
+
|
118
|
+
filter1 = Book.filter( title: /title/ )
|
119
|
+
filter2 = Book.filter( price: (1..2000) )
|
120
|
+
filter3 = Book.filter( style: ["A4","A5"] )
|
121
|
+
Book.not( filter1 ).each do |book|
|
122
|
+
p book
|
123
|
+
end
|
124
|
+
Book.and( filter1, filter2 ).each do |book|
|
125
|
+
p book
|
126
|
+
end
|
127
|
+
Book.or( filter1, filter3 ).each do |book|
|
128
|
+
p book
|
129
|
+
end
|
130
|
+
|
131
|
+
Book.find( {}, { projection: {_id: 0} } ).each do |book|
|
132
|
+
p book
|
133
|
+
end
|
119
134
|
----
|
120
135
|
|
121
136
|
=== ドキュメント更新
|
data/lib/mongous/extention.rb
CHANGED
@@ -95,6 +95,10 @@ module Mongous
|
|
95
95
|
self.new( **doc ).save
|
96
96
|
end
|
97
97
|
|
98
|
+
def find( conditios = {}, options = {} )
|
99
|
+
self.collection.find( conditios, options )
|
100
|
+
end
|
101
|
+
|
98
102
|
def field( label, *args, **opts, &block )
|
99
103
|
m = /(.*?):(\d+)/.match( caller()[0] )
|
100
104
|
call_from = [ m[1], m[2] ].join(":")
|
data/lib/mongous/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
require "mongous"
|
3
|
+
|
4
|
+
Mongous.connect!
|
5
|
+
|
6
|
+
class Book
|
7
|
+
include Mongous::Document
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
p book = Book.find.first
|
12
|
+
puts
|
13
|
+
|
14
|
+
Book.find.each do |book|
|
15
|
+
p book
|
16
|
+
end
|
17
|
+
puts
|
18
|
+
|
19
|
+
Book.find( title: /title/ ).each do |book|
|
20
|
+
p book
|
21
|
+
end
|
22
|
+
puts
|
23
|
+
|
24
|
+
Book.find( {}, { projection: {_id: 0} } ).each do |book|
|
25
|
+
p book
|
26
|
+
end
|
27
|
+
puts
|
28
|
+
|
29
|
+
Book.find( {title: /title/}, { projection: {_id: 0} } ).each do |book|
|
30
|
+
p book
|
31
|
+
end
|
32
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arimay
|
@@ -104,7 +104,7 @@ files:
|
|
104
104
|
- sample/query_limit_1.rb
|
105
105
|
- sample/query_order_1.rb
|
106
106
|
- sample/query_projection_1.rb
|
107
|
-
- sample/
|
107
|
+
- sample/query_super_1.rb
|
108
108
|
- sample/save_basic_1.rb
|
109
109
|
- sample/save_basic_2.rb
|
110
110
|
- sample/save_basic_3.rb
|
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
|
-
|