mongous 0.1.2 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f126c03248f80e7dd9c674ddff08879a994ecf36d8c443d0bb43694f6a6fd53
4
- data.tar.gz: d9c694cfd344075ec4d744a71562281ba61dac5c3df011154df0b65cd443041e
3
+ metadata.gz: 3ac08d4dc3cd1b50de8ae75c4db5f63b9604abefa5890f046564d44619d75cf4
4
+ data.tar.gz: 446aae2fcd699ad4a27cc5f15790a00d84eaceff3e38ef4ded3b5aec425dcba4
5
5
  SHA512:
6
- metadata.gz: 867d5753bac0b0a1bea9b82b4a650fcda7233465cc9e03529488e533464ec86a0d9e387afa220bdc019de07522af96e53e644fbbd92d9e5e465c69af47b9b15e
7
- data.tar.gz: e0cf057b86df920b3e2f47c26c6fedb8bcbf2ccdb5232cebb3ba3b0fd02ee7b71c90274e0ac3a168d01c5d4cd396131ba5872e286c039b91103924e1bb752689
6
+ metadata.gz: ce0e4ff3b90f13ac1bdb328ecac4c8986120e780575dbb97a242638d2cfd2c11581963cc2141c2f09f3a184cdcef85420354f4a12d02eca890c66b1458c9ea8e
7
+ data.tar.gz: 6e78c1a620e8cdc974e9e60bca01f54b0127b225a7e1e0f567c7354ec7d43adf1cd2e3ffa72859f6805ffcacd8b3a198258763a4f14ab0f216b6f4d585d56e0d
@@ -30,7 +30,7 @@ Or install it yourself as:
30
30
 
31
31
  == Usage
32
32
 
33
- === Simple description
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,25 @@ 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( { title: /title/ }, { projection: {_id: 0} } ).each do |book|
132
+ p book
133
+ end
134
+
135
+ pp Book.filter( title: /title/ )[0, 5].all
119
136
  ----
120
137
 
121
138
  === Update document
@@ -172,6 +189,19 @@ Mongous.connect( hosts_or_uri = nil, **opts )
172
189
  include Mongous::Document
173
190
  ----
174
191
 
192
+ === Bind another database.
193
+
194
+ [source,ruby]
195
+ ----
196
+ set_client( client )
197
+ ----
198
+
199
+ * Result:
200
+ ** nil.
201
+
202
+ * Parameter:
203
+ ** client: Mongo::Client instance.
204
+
175
205
  === Declare document structure.
176
206
 
177
207
  [source,ruby]
@@ -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,25 @@ 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( { title: /title/ }, { projection: {_id: 0} } ).each do |book|
132
+ p book
133
+ end
134
+
135
+ pp Book.filter( title: /title/ )[0, 5].all
119
136
  ----
120
137
 
121
138
  === ドキュメント更新
@@ -172,6 +189,19 @@ Mongous.connect( hosts_or_uri = nil, **opts )
172
189
  include Mongous::Document
173
190
  ----
174
191
 
192
+ === 別のデータベースを割り当てる.
193
+
194
+ [source,ruby]
195
+ ----
196
+ set_client( client )
197
+ ----
198
+
199
+ * Result:
200
+ ** nil.
201
+
202
+ * Parameter:
203
+ ** client: Mongo::Client instance.
204
+
175
205
  === ドキュメントの要素を定義する.
176
206
 
177
207
  [source,ruby]
@@ -7,9 +7,9 @@ module Mongous
7
7
  end
8
8
  end
9
9
 
10
- def initialize( doc = nil, **hash )
10
+ def initialize( **doc )
11
11
  @doc = {}
12
- (doc || hash).each do |label, value|
12
+ doc.each do |label, value|
13
13
  label = label.to_s
14
14
  @doc[label] = value
15
15
  end
@@ -10,7 +10,7 @@ module Mongous
10
10
  end
11
11
  end
12
12
 
13
- def set_client( _client )
13
+ def client=( _client )
14
14
  m = /(.*?):(\d+)/.match( caller()[0] )
15
15
  call_from = [ m[1], m[2] ].join(":")
16
16
  if !_client.is_a?( Mongo::Client )
@@ -28,7 +28,7 @@ module Mongous
28
28
  end
29
29
  end
30
30
 
31
- def set_collection_name( _collection_name )
31
+ def collection_name=( _collection_name )
32
32
  self.class_variable_set( :@@collection_name, _collection_name )
33
33
  if self.class_variable_defined?( :@@collection )
34
34
  self.remove_class_variable( :@@collection )
@@ -91,28 +91,12 @@ module Mongous
91
91
  end
92
92
  end
93
93
 
94
- def create( doc = nil, **hash )
95
- self.new( doc || hash ).save
94
+ def create( **doc )
95
+ self.new( **doc ).save
96
96
  end
97
97
 
98
- def filter( **_filter )
99
- Filter.new( self ).filter( _filter )
100
- end
101
-
102
- def first
103
- Filter.new( self ).first
104
- end
105
-
106
- def all
107
- Filter.new( self ).all
108
- end
109
-
110
- def each( &block )
111
- Filter.new( self ).each( &block )
112
- end
113
-
114
- def delete
115
- Filter.new( self ).delete
98
+ def find( conditios = {}, options = {} )
99
+ self.collection.find( conditios, options )
116
100
  end
117
101
 
118
102
  def field( label, *args, **opts, &block )
@@ -1,4 +1,82 @@
1
1
 
2
+ module Mongous
3
+ module Extention
4
+ def count
5
+ self.collection.find.count
6
+ end
7
+
8
+ def first
9
+ doc = self.collection.find.first
10
+ self.new( **doc ) if doc
11
+ end
12
+
13
+ def all
14
+ self.collection.find.map do |doc|
15
+ self.new( **doc )
16
+ end
17
+ end
18
+
19
+ def each( &block )
20
+ all.each( &block )
21
+ end
22
+
23
+ def delete
24
+ self.collection.delete_many({})
25
+ end
26
+
27
+ def filter( **conditions )
28
+ Filter.new( self ).filter( conditions )
29
+ end
30
+
31
+ def not( filter = nil, **conditions )
32
+ raise Mongous::Error, "Unset args for #{self}.not." if filter.nil? && conditions.empty?
33
+
34
+ filter ||= conditions
35
+ condition = case filter
36
+ when Hash
37
+ Filter.new( self ).filter( filter ).to_condition
38
+ when Filter
39
+ filter.to_condition
40
+ else
41
+ raise Mongous::Error, "Invalid args for #{self}.not. : #{filter}"
42
+ end
43
+ Filter.new( self ).filter({"$nor" => [condition]})
44
+ end
45
+
46
+ def and( *filters )
47
+ raise Mongous::Error, "Unset args for #{self}.and." if filters.empty?
48
+
49
+ conditions = filters.map do |filter|
50
+ case filter
51
+ when Hash
52
+ filter
53
+ when Filter
54
+ filter.to_condition
55
+ else
56
+ raise Mongous::Error, "Invalid args for #{self}.and. : #{filter}"
57
+ end
58
+ end
59
+ Filter.new( self ).filter({"$and" => conditions})
60
+ end
61
+
62
+ def or( *filters )
63
+ raise Mongous::Error, "Unset args for #{self}.or." if filters.empty?
64
+
65
+ conditions = filters.map do |filter|
66
+ case filter
67
+ when Hash
68
+ filter
69
+ when Filter
70
+ filter.to_condition
71
+ else
72
+ raise Mongous::Error, "Invalid args for #{self}.or. : #{filter}"
73
+ end
74
+ end
75
+ Filter.new( self ).filter({"$or" => conditions})
76
+ end
77
+ end
78
+ end
79
+
2
80
  module Mongous
3
81
  class Filter
4
82
  def initialize( klass )
@@ -7,86 +85,104 @@ module Mongous
7
85
  @option = {}
8
86
  end
9
87
 
10
- def filter( _filter )
88
+ def filter( conditions )
11
89
  hash = {}
12
- _filter.each do |key, item|
13
- case item
14
- when Array
15
- hash[key] = {"$in"=>item}
90
+ conditions.each do |key, item|
91
+ case key
92
+ when /\$(and|or|nor)/
93
+ hash[key] = item
16
94
 
17
- when Range
18
- _begin_oper = "$gte"
19
- _end_oper = item.exclude_end? ? "$lt" : "$lte"
95
+ else
96
+ case item
97
+ when Array
98
+ hash[key] = {"$in"=>item}
20
99
 
21
- if item.begin && item.end
22
- hash[key] = { _begin_oper => item.begin, _end_oper => item.end }
100
+ when Range
101
+ _begin_oper = "$gte"
102
+ _end_oper = item.exclude_end? ? "$lt" : "$lte"
23
103
 
24
- elsif !item.begin && item.end
25
- hash[key] = { _end_oper => item.end }
104
+ if item.begin && item.end
105
+ hash[key] = { _begin_oper => item.begin, _end_oper => item.end }
26
106
 
27
- elsif item.begin && !item.end
28
- hash[key] = { _begin_oper => item.begin }
107
+ elsif !item.begin && item.end
108
+ hash[key] = { _end_oper => item.end }
29
109
 
30
- else
31
- raise Mongous::Error, "invalid range. : #{ item }"
110
+ elsif item.begin && !item.end
111
+ hash[key] = { _begin_oper => item.begin }
32
112
 
33
- end
113
+ else
114
+ raise Mongous::Error, "invalid range. : #{ item }"
34
115
 
35
- else
36
- hash[key] = item
116
+ end
37
117
 
118
+ else
119
+ hash[key] = item
120
+
121
+ end
38
122
  end
39
123
  end
40
124
  @filter.merge!( hash )
41
125
  self.dup
42
126
  end
43
127
 
44
- def option( _option )
45
- self.option!( _option )
46
- self.dup
128
+ def to_condition
129
+ @filter.dup
47
130
  end
48
131
 
49
- def option!( _option )
132
+ def option( _option )
50
133
  @option.merge!( _option )
134
+ self.dup
51
135
  end
52
136
 
53
137
  def projection( _projection )
54
- self.projection!( _projection )
138
+ @projection = _projection
55
139
  self.dup
56
140
  end
57
141
  alias :select :projection
58
142
 
59
- def projection!( _projection )
60
- @projection = _projection
61
- end
62
-
63
143
  def sort( _sort )
64
- self.sort!( _sort )
144
+ @sort = _sort
65
145
  self.dup
66
146
  end
67
147
  alias :order :sort
68
148
 
69
- def sort!( _sort )
70
- @sort = _sort
71
- end
72
-
73
149
  def skip( _skip )
74
- self.skip!( _skip )
150
+ @skip = _skip
75
151
  self.dup
76
152
  end
77
153
  alias :offset :skip
78
154
 
79
- def skip!( _skip )
80
- @skip = _skip
81
- end
82
-
83
155
  def limit( _limit )
84
- self.limit!( _limit )
156
+ @limit = _limit
85
157
  self.dup
86
158
  end
87
159
 
88
- def limit!( _limit )
89
- @limit = _limit
160
+ def []( nth_or_range, len = 1 )
161
+ case nth_or_range
162
+ when Integer
163
+ raise Mongous::Error, "invalid nth. : #{ nth_or_range }" if len < 0
164
+ @skip = nth_or_range
165
+
166
+ raise Mongous::Error, "invalid len. : #{ len }" if !len.is_a? Integer || len <= 0
167
+ @limit = len
168
+
169
+ when Range
170
+ from = nth_or_range.begin
171
+ raise Mongous::Error, "invalid range. : #{ nth_or_range }" unless from.is_a? Integer
172
+
173
+ to = nth_or_range.end
174
+ raise Mongous::Error, "invalid range. : #{ nth_or_range }" unless to.is_a? Integer
175
+
176
+ to -= 1 if nth_or_range.exclude_end?
177
+ @skip = from
178
+ @limit = to - from + 1
179
+
180
+ else
181
+ raise Mongous::Error, "invalid class. : #{ nth_or_range }"
182
+
183
+ end
184
+
185
+ self.dup
90
186
  end
91
187
 
92
188
  def do_find
@@ -100,14 +196,27 @@ module Mongous
100
196
  found
101
197
  end
102
198
 
199
+ def count
200
+ _count = do_find.count
201
+ if @skip && @limit
202
+ [_count - @skip, @limit].min
203
+ elsif @skip.nil? && @limit
204
+ [_count, @limit].min
205
+ elsif @skip && @limit.nil?
206
+ [_count - @skip, 0].max
207
+ else
208
+ _count
209
+ end
210
+ end
211
+
103
212
  def first
104
213
  doc = do_find.first
105
- @klass.new( doc ) if doc
214
+ @klass.new( **doc ) if doc
106
215
  end
107
216
 
108
217
  def all
109
218
  do_find.map do |doc|
110
- @klass.new( doc )
219
+ @klass.new( **doc )
111
220
  end
112
221
  end
113
222
 
@@ -1,3 +1,3 @@
1
1
  module Mongous
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -3,12 +3,13 @@ require_relative 'lib/mongous/version'
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "mongous"
5
5
  spec.version = Mongous::VERSION
6
- spec.authors = ["ARIMA Yasuhiro"]
6
+ spec.authors = ["arimay"]
7
7
  spec.email = ["arima.yasuhiro@gmail.com"]
8
8
 
9
9
  spec.summary = %q{ Mongo wrapper library. }
10
10
  spec.description = %q{ Yet another lightweight mongo wrapper library. }
11
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
11
+ spec.homepage = "https://github.com/arimay/mongous"
12
+ spec.license = "MIT"
12
13
 
13
14
  # Specify which files should be added to the gem when it is released.
14
15
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -5,7 +5,8 @@ $client = Mongous.connect
5
5
 
6
6
  class Book
7
7
  include Mongous::Document
8
- set_client $client
8
+ self.client = $client
9
+ self.collection_name = "Book"
9
10
  end
10
11
 
11
12
 
@@ -5,7 +5,8 @@ $client = Mongous.connect( ["localhost:27017"], database: "test" )
5
5
 
6
6
  class Book
7
7
  include Mongous::Document
8
- set_client $client
8
+ self.client = $client
9
+ self.collection_name = "Book"
9
10
  end
10
11
 
11
12
 
@@ -5,7 +5,8 @@ $client = Mongous.connect( ENV["MONGOLAB_URI"] || "mongodb://localhost:27017/t
5
5
 
6
6
  class Book
7
7
  include Mongous::Document
8
- set_client $client
8
+ self.client = $client
9
+ self.collection_name = "Book"
9
10
  end
10
11
 
11
12
 
@@ -6,7 +6,8 @@ $client = Mongous.connect( file: filepath, mode: ENV["RACK_ENV"] || "developme
6
6
 
7
7
  class Book
8
8
  include Mongous::Document
9
- set_client $client
9
+ self.client = $client
10
+ self.collection_name = "Book"
10
11
  end
11
12
 
12
13
 
@@ -8,11 +8,17 @@ class Book
8
8
  end
9
9
 
10
10
 
11
- book = Book.first
12
- p book
11
+ p book = Book.first
12
+ puts
13
+
14
+ p count = Book.count
15
+ puts
16
+
17
+ pp books = Book.all
13
18
  puts
14
19
 
15
20
  Book.each do |book|
16
21
  p book
17
22
  end
23
+ puts
18
24
 
@@ -8,11 +8,17 @@ class Book
8
8
  end
9
9
 
10
10
 
11
- book = Book.filter( title: "title 1" ).first
12
- p book
11
+ p book = Book.filter( title: /title/ ).first
12
+ puts
13
+
14
+ p count = Book.filter( title: /title/ ).count
15
+ puts
16
+
17
+ pp books = Book.filter( title: /title/ ).all
13
18
  puts
14
19
 
15
20
  Book.filter( title: /title/ ).each do |book|
16
21
  p book
17
22
  end
23
+ puts
18
24
 
@@ -18,22 +18,3 @@ Book.filter( page: (100...300) ).each do |book|
18
18
  end
19
19
  puts
20
20
 
21
- exit if RUBY_VERSION < "2.6"
22
-
23
- Book.filter( page: (200..) ).each do |book|
24
- p book
25
- end
26
- puts
27
-
28
- exit if RUBY_VERSION < "2.7"
29
-
30
- Book.filter( page: (..200) ).each do |book|
31
- p book
32
- end
33
- puts
34
-
35
- Book.filter( page: (...300) ).each do |book|
36
- p book
37
- end
38
- puts
39
-
@@ -0,0 +1,43 @@
1
+
2
+ require "mongous"
3
+
4
+ Mongous.connect!
5
+
6
+ class Book
7
+ include Mongous::Document
8
+ end
9
+
10
+ Book.new( title: "complex 1", author: "Alice", style: "A4", price: 1000, page: 100 ).save
11
+ Book.new( title: "complex 2", author: "Bob", style: "A5", price: 2000, page: 200 ).save
12
+ Book.new( title: "complex 3", author: "Candy", style: "A6", price: 3000, page: 300 ).save
13
+
14
+ filter1 = Book.filter( title: /comp/ )
15
+ filter2 = Book.not( price: (2000...3000) )
16
+ filter3 = Book.and( filter1, filter2 ).select( _id: 0 )
17
+ filter4 = Book.or( filter1, filter2 ).select( _id: 0 )
18
+ p filter1.to_condition
19
+ p filter2.to_condition
20
+ p filter3.to_condition
21
+ p filter4.to_condition
22
+ puts
23
+
24
+ filter1.each do |book|
25
+ p book
26
+ end
27
+ puts
28
+
29
+ filter2.each do |book|
30
+ p book
31
+ end
32
+ puts
33
+
34
+ filter3.each do |book|
35
+ p book
36
+ end
37
+ puts
38
+
39
+ filter4.each do |book|
40
+ p book
41
+ end
42
+ puts
43
+
@@ -0,0 +1,38 @@
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
+
@@ -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
+
@@ -9,10 +9,10 @@ end
9
9
 
10
10
 
11
11
  book = Book.new
12
- book.title = "title basic 2"
13
- book.author = "Bob"
14
- book.style = "A5"
15
- book.price = 2000
16
- book.page = 200
12
+ book.title = "title basic 1"
13
+ book.author = "Alice"
14
+ book.style = "A4"
15
+ book.price = 1000
16
+ book.page = 100
17
17
  book.save
18
18
 
@@ -8,6 +8,6 @@ class Book
8
8
  end
9
9
 
10
10
 
11
- book = Book.new( title: "title basic 1", author: "Alice", style: "A4", price: 1000, page: 100 )
11
+ book = Book.new( title: "title basic 2", author: "Bob", style: "A5", price: 2000, page: 200 )
12
12
  book.save
13
13
 
@@ -9,5 +9,5 @@ end
9
9
 
10
10
 
11
11
  doc = { title: "title basic 3", author: "Candy", style: "A6", price: 3000, page: 300 }
12
- Book.create( doc )
12
+ Book.create( **doc )
13
13
 
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.2
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
- - ARIMA Yasuhiro
7
+ - arimay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-30 00:00:00.000000000 Z
11
+ date: 2020-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo
@@ -97,13 +97,15 @@ files:
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
+ - sample/query_basic_7.rb
100
102
  - sample/query_detail_1.rb
101
103
  - sample/query_detail_2.rb
102
104
  - sample/query_detail_3.rb
103
105
  - sample/query_limit_1.rb
104
106
  - sample/query_order_1.rb
105
107
  - sample/query_projection_1.rb
106
- - sample/query_raw_1.rb
108
+ - sample/query_super_1.rb
107
109
  - sample/save_basic_1.rb
108
110
  - sample/save_basic_2.rb
109
111
  - sample/save_basic_3.rb
@@ -121,8 +123,9 @@ files:
121
123
  - sample/zap_basic_1.rb
122
124
  - sample/zap_basic_2.rb
123
125
  - sample/zap_basic_3.rb
124
- homepage:
125
- licenses: []
126
+ homepage: https://github.com/arimay/mongous
127
+ licenses:
128
+ - MIT
126
129
  metadata: {}
127
130
  post_install_message:
128
131
  rdoc_options: []
@@ -132,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
135
  requirements:
133
136
  - - ">="
134
137
  - !ruby/object:Gem::Version
135
- version: 2.6.0
138
+ version: '0'
136
139
  required_rubygems_version: !ruby/object:Gem::Requirement
137
140
  requirements:
138
141
  - - ">="
@@ -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
-