mongous 0.1.4 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +156 -37
  3. data/README.ja.adoc +155 -36
  4. data/lib/mongous/document.rb +66 -31
  5. data/lib/mongous/extention.rb +59 -46
  6. data/lib/mongous/filter.rb +82 -60
  7. data/lib/mongous/version.rb +1 -1
  8. data/sample/connect_auto_2.rb +2 -1
  9. data/sample/connect_default_2.rb +2 -1
  10. data/sample/connect_environ_2.rb +2 -1
  11. data/sample/connect_loadfile_2.rb +2 -1
  12. data/sample/declare_compact_1.rb +4 -3
  13. data/sample/declare_label_1.rb +5 -3
  14. data/sample/declare_ndex_1.rb +5 -3
  15. data/sample/declare_ndex_2.rb +5 -3
  16. data/sample/declare_strict_1.rb +14 -10
  17. data/sample/declare_strict_2.rb +5 -3
  18. data/sample/{multi_docs_1.rb → multi_collection_1.rb} +0 -0
  19. data/sample/multi_collection_2.rb +63 -0
  20. data/sample/query_basic_1.rb +3 -1
  21. data/sample/query_basic_2.rb +5 -3
  22. data/sample/query_basic_3.rb +2 -3
  23. data/sample/query_basic_4.rb +3 -4
  24. data/sample/query_basic_5.rb +2 -3
  25. data/sample/query_detail_1.rb +1 -0
  26. data/sample/query_detail_2.rb +1 -0
  27. data/sample/query_detail_3.rb +5 -3
  28. data/sample/{query_basic_6.rb → query_filter_1.rb} +8 -5
  29. data/sample/query_filter_2.rb +50 -0
  30. data/sample/query_find_1.rb +31 -0
  31. data/sample/query_projection_1.rb +5 -8
  32. data/sample/query_skip_limit_1.rb +47 -0
  33. data/sample/query_skip_limit_2.rb +49 -0
  34. data/sample/query_sort_order_1.rb +46 -0
  35. data/sample/save_basic_1.rb +1 -2
  36. data/sample/save_basic_2.rb +1 -2
  37. data/sample/save_basic_3.rb +1 -2
  38. data/sample/save_detail_1.rb +7 -4
  39. data/sample/save_detail_2.rb +7 -4
  40. data/sample/save_detail_3.rb +10 -7
  41. data/sample/save_verify_1.rb +7 -4
  42. data/sample/save_verify_3.rb +1 -1
  43. data/sample/save_verify_5.rb +3 -3
  44. data/sample/save_verify_6.rb +3 -3
  45. data/sample/save_verify_7.rb +23 -0
  46. data/sample/update_basic_1.rb +13 -0
  47. data/sample/zap_basic_2.rb +2 -2
  48. metadata +12 -11
  49. data/sample/multi_docs_2.rb +0 -58
  50. data/sample/query_limit_1.rb +0 -44
  51. data/sample/query_order_1.rb +0 -49
  52. data/sample/query_raw_1.rb +0 -33
  53. data/sample/template_article.rb +0 -5
  54. data/sample/template_person.rb +0 -12
  55. data/sample/zap_basic_3.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8625111477cf919df2db565a10a074c1634be763e2608ba11f27c700225b84c9
4
- data.tar.gz: 6ff1ca08f9180c3e3272746f2fbb155b1e2b723686c5089222c61707b7868eab
3
+ metadata.gz: dded44fdc39ecb6ff4eeb6db10183e3a940f19317062a73d85ecf4d4c6e10437
4
+ data.tar.gz: 34fa872a88fdc0aac33101465a490fb71f9132542e7f4583f86313527c532d9b
5
5
  SHA512:
6
- metadata.gz: a90f92e753dc4e634bf8939760ca3808a995fc73fc76d929028a03b7cb66fd50d3c42895ba54795c72205c3906636850f2f794279e8615c1e21d28a67716cd6b
7
- data.tar.gz: fcb2cf7f85a660635a552410a37febf03165538a708a93d4760a11ea3645752c2d4f1bd3ee38971d040e75e36ca9c44ecf6ce26d80a3fafb40d6a06eee52a650
6
+ metadata.gz: 1b39238447cf6419f663b22563930a5e32671983e29395bfc31dabeaf77d1dfca3ff7dbd84e54b8e231c9f8810729c2701d491b7ae9e3e8171eda400a97bf041
7
+ data.tar.gz: 7660804d5e3452714dbcbe0ac30a532789dbc553f3e5929ec58d4f0dfafd4bb9bd4dc0cb8aa124265c9af6dd6ac25acfc1361b4fa239317fc2a5bde26eb2e932
@@ -5,9 +5,12 @@ Yet another mongo wrapper library.
5
5
  == Features
6
6
 
7
7
  * A light library that depends only on the mongo driver and bson, except for built-in and standard attachments.
8
- * Item default value can be described in the block.
9
- * Item constraints can be described by Array, Range, and Proc.
10
- * Checks that constraints are met when saving and setting values.
8
+ * Document item constraints can be described in Array, Range, Regexp, Proc instances, or base classes.
9
+ * Check if the constraint conditions are met when saving the document.
10
+ * Check if the constraint condition is satisfied when setting the item value of the document.
11
+ * The contents of undefined items in the document can be described by value or Proc.
12
+ * Item settings can be described in values or Proc when creating a document.
13
+ * Item settings can be described in values or Proc when updating the document.
11
14
 
12
15
  == Installation
13
16
 
@@ -30,7 +33,7 @@ Or install it yourself as:
30
33
 
31
34
  == Usage
32
35
 
33
- === Simple description
36
+ === Simple declaration
34
37
 
35
38
  [source,ruby]
36
39
  ----
@@ -57,12 +60,16 @@ class Book
57
60
  field :title, String, :must
58
61
  field :author, String
59
62
  field :publisher, String
60
- field :style, String, ["A4","B5","A5","B6"]
61
- field :price, Integer, (0..1_000_000)
62
- field :page, Integer, proc{ page % 4 == 0 }
63
- field :publish_at, Date, &proc{ Date.today }
64
- field :isbn, String, proc{ isbn? }
65
- field :lang, String, &proc{ "ja" }
63
+ field :style, String, %w[hardcover, softcover, paperback]
64
+ field :size, String, /[AB]\d/
65
+ field :price, Integer, (0..1_000_000)
66
+ field :page, Integer, proc{ page % 4 == 0 }
67
+ field :isbn, String, proc{ isbn? }
68
+ field :lang, String, default: "en"
69
+ field :created_at, Time, create: proc{ Time.now }
70
+ field :updated_at, Time, update: proc{ Time.now }
71
+
72
+ filter :foobar, {title: /foobar/}
66
73
 
67
74
  verify :strict
68
75
  verify do
@@ -84,45 +91,64 @@ end
84
91
  book = Book.new
85
92
  book.title = "title 1"
86
93
  book.price = 1000
87
- book.style = "A4"
94
+ book.size = "A4"
88
95
  book.save
89
96
 
90
- book = Book.new( title: "title 2", price: 2000, style: "A5" )
97
+ book = Book.new( title: "title 2", price: 2000, size: "A5" )
91
98
  book.save
92
99
 
93
- doc = { title: "title 3", price: 3000, style: "A6" }
94
- Book.create( doc )
100
+ doc = { title: "title 3", price: 3000, size: "A6" }
101
+ Book.create( **doc )
95
102
  ----
96
103
 
97
104
  === Search document
98
105
 
99
106
  [source,ruby]
100
107
  ----
101
- books = Book.all
102
- pp books
108
+ pp books = Book.all
103
109
 
104
- book = Book.filter( title: "title 1" ).first
105
- p book
110
+ p book = Book.where( title: "title 1" ).first
106
111
 
107
- books = Book.filter( title: /title/ ).all
112
+ books = Book.where( title: /title/ ).all
108
113
  books.each do |book|
109
114
  p book
110
115
  end
111
116
 
112
- Book.filter( title: /title/ ).projection( _id: 0 ).each do |book|
117
+ Book.where( title: /title/ ).projection( _id: 0 ).each do |book|
113
118
  p book
114
119
  end
115
120
 
116
- Book.filter( price: (1..2000), style: ["A4","A5"] ).each do |book|
121
+ Book.where( price: (1..2000), size: ["A4","A5"] ).each do |book|
122
+ p book
123
+ end
124
+
125
+ filter1 = Book.where( title: /title/ )
126
+ filter2 = Book.where( :foobar )
127
+ filter3 = Book.where( price: (1..2000) )
128
+ filter4 = Book.where( size: ["A4","A5"] )
129
+
130
+ Book.not( filter1 ).each do |book|
117
131
  p book
118
132
  end
133
+ Book.and( filter1, filter3 ).each do |book|
134
+ p book
135
+ end
136
+ Book.or( filter2, filter4 ).each do |book|
137
+ p book
138
+ end
139
+
140
+ Book.find( { title: /title/ }, { projection: {_id: 0} } ).each do |book|
141
+ p book
142
+ end
143
+
144
+ pp Book.where( title: /title/ )[0, 5].all
119
145
  ----
120
146
 
121
147
  === Update document
122
148
 
123
149
  [source,ruby]
124
150
  ----
125
- book = Book.filter( title: "title 1" ).first
151
+ book = Book.where( title: "title 1" ).first
126
152
  book.title = "title 1 [update]"
127
153
  book.save
128
154
  ----
@@ -131,7 +157,7 @@ book.save
131
157
 
132
158
  [source,ruby]
133
159
  ----
134
- book = Book.filter( title: "title 1" ).first
160
+ book = Book.where( title: "title 1" ).first
135
161
  book.delete
136
162
  ----
137
163
 
@@ -141,7 +167,7 @@ book.delete
141
167
 
142
168
  [source,ruby]
143
169
  ----
144
- Mongous.connect!( hosts_or_uri = nil, **opts )
170
+ Mongous.connect!( hosts_or_uri = nil, **options )
145
171
  ----
146
172
 
147
173
  * Result:
@@ -149,21 +175,21 @@ Mongous.connect!( hosts_or_uri = nil, **opts )
149
175
 
150
176
  * Parameter:
151
177
  ** hosts_or_uri: Array of hosts, or URI (default: ["localhost:21017"])
152
- ** opts: Options.
178
+ ** options: Options.
153
179
  *** file: Path to database configuration file.
154
180
  *** mode: Execution mode. (default: "development")
155
181
  *** database: Database name. (default: "test")
156
- *** * Other optional arguments for Mongo::Client.new.
182
+ *** Other optional arguments for Mongo::Client.new.
157
183
 
158
184
  === Connect database.
159
185
 
160
186
  [source,ruby]
161
187
  ----
162
- Mongous.connect( hosts_or_uri = nil, **opts )
188
+ Mongous.connect( hosts_or_uri = nil, **options )
163
189
  ----
164
190
 
165
191
  * Result:
166
- ** Mongo::Client.
192
+ ** Mongo::Client instance.
167
193
 
168
194
  === Include document functions.
169
195
 
@@ -172,33 +198,62 @@ Mongous.connect( hosts_or_uri = nil, **opts )
172
198
  include Mongous::Document
173
199
  ----
174
200
 
201
+ === Bind another database.
202
+
203
+ [source,ruby]
204
+ ----
205
+ self.client=( _client )
206
+ ----
207
+
208
+ * Result:
209
+ ** Mongo::Client instance.
210
+
211
+ * Parameter:
212
+ ** client: Mongo::Client instance.
213
+
214
+ === Bind another collection.
215
+
216
+ [source,ruby]
217
+ ----
218
+ self.collection_name=( _collection_name )
219
+ ----
220
+
221
+ * Result:
222
+ ** Collection name string.
223
+
224
+ * Parameter:
225
+ ** collection_name: Collection name.
226
+
175
227
  === Declare document structure.
176
228
 
177
229
  [source,ruby]
178
230
  ----
179
- field( label, *attrs, &block )
231
+ field( symbol, *attrs, **items )
180
232
  ----
181
233
 
182
234
  * Parameter:
183
- ** label: Field label symbol.
235
+ ** symbol: Field name.
184
236
  ** attrs: Field attributes.
185
237
  *** Class: Class for field verification.
186
238
  *** Proc: Proc for field verification.
187
239
  *** Range: Range for field verification.
188
240
  *** Array: Array for field verification.
189
- *** Symbol: Special delectives.
241
+ *** Symbol: Special directive symbol.
190
242
  **** must: Not nil nor empty.
191
- ** block: Returning default value.
243
+ ** items: Operation when saving.
244
+ *** default: Value or proc when undefined.
245
+ *** create: Value or proc when saving a new document.
246
+ *** update: Value or proc when saving update document.
192
247
 
193
248
  === Verify before save or assignment action.
194
249
 
195
250
  [source,ruby]
196
251
  ----
197
- verify( *syms, &block )
252
+ verify( *directives, &block )
198
253
  ----
199
254
 
200
255
  * Parameter:
201
- ** syms: Conditional symbols.
256
+ ** directives: Special directive symbol.
202
257
  *** strict: Verify that it is a defined item name.
203
258
  ** block: Describe the content that verifies each item value and returns the truth.
204
259
 
@@ -206,12 +261,12 @@ verify( *syms, &block )
206
261
 
207
262
  [source,ruby]
208
263
  ----
209
- index( *syms, **opts )
264
+ index( *symbols, **options )
210
265
  ----
211
266
 
212
267
  * Parameter:
213
- ** syms: Field label symbols.
214
- ** opts: Options for Mongo::Collection#indexes().
268
+ ** symbols: Field names.
269
+ ** options: Options for Mongo::Collection#indexes().
215
270
 
216
271
  === Verify field value is not nil nor empty.
217
272
 
@@ -226,6 +281,70 @@ having?( label )
226
281
  * Parameter:
227
282
  ** label: Field label for method call.
228
283
 
284
+ === Name the search condition.
285
+
286
+ [source,ruby]
287
+ ----
288
+ filter( symbol, filter_or_cond )
289
+ ----
290
+
291
+ * Parameter:
292
+ ** symbol: Filter name.
293
+ ** filter_or_cond: Filter or search criteria.
294
+
295
+ === Search condition.
296
+
297
+ [source,ruby]
298
+ ----
299
+ where( filter = nil, **conditions )
300
+ ----
301
+
302
+ * Result:
303
+ ** Filter instance.
304
+
305
+ * Parameter:
306
+ ** filter: Filter name symbol, or filter instance.
307
+ ** conditions: Search criteria.
308
+
309
+ === NOT search condition.
310
+
311
+ [source,ruby]
312
+ ----
313
+ not( filter = nil, **conditions )
314
+ ----
315
+
316
+ * Result:
317
+ ** Filter instance.
318
+
319
+ * Parameter:
320
+ ** filter: Filter name symbol, or filter instance.
321
+ ** conditions: Search criteria.
322
+
323
+ === AND search condition.
324
+
325
+ [source,ruby]
326
+ ----
327
+ and( *filters )
328
+ ----
329
+
330
+ * Result:
331
+ ** Filter instance.
332
+
333
+ * Parameter:
334
+ ** filters: Filter name symbol, or filter instance.
335
+
336
+ === OR search condition.
337
+
338
+ [source,ruby]
339
+ ----
340
+ or( *filters )
341
+ ----
342
+
343
+ * Result:
344
+ ** Filter instance.
345
+
346
+ * Parameter:
347
+ ** filters: Field name symbol, or filter instance.
229
348
 
230
349
  == Contributing
231
350
 
@@ -5,9 +5,12 @@
5
5
  == 特徴
6
6
 
7
7
  * 組込みと標準添付を除いて、mongo driver と bson のみに依存する軽いライブラリである。
8
- * 項目デフォルト値をブロックで記述できる.
9
- * 項目制約条件を Array, Range, Proc で記述できる.
10
- * 保存時および値設定時に制約条件を満たすか検査する.
8
+ * ドキュメント項目の制約条件を Array, Range, Regexp, Proc インスタンスまたは基本クラスで記述できる.
9
+ * ドキュメント保存時に制約条件を満たすか検査する.
10
+ * ドキュメントの項目値設定時に制約条件を満たすか検査する.
11
+ * ドキュメントの未定義項目の内容を値または Proc で記述できる.
12
+ * ドキュメントの作成時に項目設定内容を値または Proc で記述できる.
13
+ * ドキュメントの更新時に項目設定内容を値または Proc で記述できる.
11
14
 
12
15
  == 導入
13
16
 
@@ -54,15 +57,19 @@ Mongous.connect! ["localhost:27017"], database: "test"
54
57
  class Book
55
58
  include Mongous::Document
56
59
 
57
- field :title, String, :must
60
+ field :title, String, :must
58
61
  field :author, String
59
62
  field :publisher, String
60
- field :style, String, ["A4","B5","A5","B6"]
61
- field :price, Integer, (0..1_000_000)
62
- field :page, Integer, proc{ page % 4 == 0 }
63
- field :publish_at, Date, &proc{ Date.today }
64
- field :isbn, String, proc{ isbn? }
65
- field :lang, String, &proc{ "ja" }
63
+ field :style, String, %w[hardcover, softcover, paperback]
64
+ field :size, String, /[AB]\d/
65
+ field :price, Integer, (0..1_000_000)
66
+ field :page, Integer, proc{ page % 4 == 0 }
67
+ field :isbn, String, proc{ isbn? }
68
+ field :lang, String, default: "en"
69
+ field :created_at, Time, create: proc{ Time.now }
70
+ field :updated_at, Time, update: proc{ Time.now }
71
+
72
+ filter :foobar, {title: /foobar/}
66
73
 
67
74
  verify :strict
68
75
  verify do
@@ -84,45 +91,64 @@ end
84
91
  book = Book.new
85
92
  book.title = "title 1"
86
93
  book.price = 1000
87
- book.style = "A4"
94
+ book.size = "A4"
88
95
  book.save
89
96
 
90
- book = Book.new( title: "title 2", price: 2000, style: "A5" )
97
+ book = Book.new( title: "title 2", price: 2000, size: "A5" )
91
98
  book.save
92
99
 
93
- doc = { title: "title 3", price: 3000, style: "A6" }
94
- Book.create( doc )
100
+ doc = { title: "title 3", price: 3000, size: "A6" }
101
+ Book.create( **doc )
95
102
  ----
96
103
 
97
104
  === ドキュメント検索
98
105
 
99
106
  [source,ruby]
100
107
  ----
101
- books = Book.all
102
- pp books
108
+ pp books = Book.all
103
109
 
104
- book = Book.filter( title: "title 1" ).first
105
- p book
110
+ p book = Book.where( title: "title 1" ).first
106
111
 
107
- books = Book.filter( title: /title/ ).all
112
+ books = Book.where( title: /title/ ).all
108
113
  books.each do |book|
109
114
  p book
110
115
  end
111
116
 
112
- Book.filter( title: /title/ ).projection( _id: 0 ).each do |book|
117
+ Book.where( title: /title/ ).projection( _id: 0 ).each do |book|
113
118
  p book
114
119
  end
115
120
 
116
- Book.filter( price: (1..2000), style: ["A4","A5"] ).each do |book|
121
+ Book.where( price: (1..2000), size: ["A4","A5"] ).each do |book|
122
+ p book
123
+ end
124
+
125
+ filter1 = Book.where( title: /title/ )
126
+ filter2 = Book.where( :foobar )
127
+ filter3 = Book.where( price: (1..2000) )
128
+ filter4 = Book.where( size: ["A4","A5"] )
129
+
130
+ Book.not( filter1 ).each do |book|
117
131
  p book
118
132
  end
133
+ Book.and( filter1, filter3 ).each do |book|
134
+ p book
135
+ end
136
+ Book.or( filter2, filter4 ).each do |book|
137
+ p book
138
+ end
139
+
140
+ Book.find( { title: /title/ }, { projection: {_id: 0} } ).each do |book|
141
+ p book
142
+ end
143
+
144
+ pp Book.where( title: /title/ )[0, 5].all
119
145
  ----
120
146
 
121
147
  === ドキュメント更新
122
148
 
123
149
  [source,ruby]
124
150
  ----
125
- book = Book.filter( title: "title 1" ).first
151
+ book = Book.where( title: "title 1" ).first
126
152
  book.title = "title 1 [update]"
127
153
  book.save
128
154
  ----
@@ -131,7 +157,7 @@ book.save
131
157
 
132
158
  [source,ruby]
133
159
  ----
134
- book = Book.filter( title: "title 1" ).first
160
+ book = Book.where( title: "title 1" ).first
135
161
  book.delete
136
162
  ----
137
163
 
@@ -141,7 +167,7 @@ book.delete
141
167
 
142
168
  [source,ruby]
143
169
  ----
144
- Mongous.connect!( hosts_or_uri = nil, **opts )
170
+ Mongous.connect!( hosts_or_uri = nil, **options )
145
171
  ----
146
172
 
147
173
  * Result:
@@ -149,21 +175,21 @@ Mongous.connect!( hosts_or_uri = nil, **opts )
149
175
 
150
176
  * Parameter:
151
177
  ** hosts_or_uri: ホスト配列または URI (default: ["localhost:21017"])
152
- ** opts: オプション
178
+ ** options: オプション
153
179
  *** file: データベース構成定義ファイルへのパス
154
180
  *** mode: 実行モード (default: "development")
155
181
  *** database: データベース名 (default: "test")
156
- *** * Mongo::Client.new のその他オプション引数
182
+ *** Mongo::Client.new のその他オプション引数
157
183
 
158
184
  === データベースに接続する
159
185
 
160
186
  [source,ruby]
161
187
  ----
162
- Mongous.connect( hosts_or_uri = nil, **opts )
188
+ Mongous.connect( hosts_or_uri = nil, **options )
163
189
  ----
164
190
 
165
191
  * Result:
166
- ** Mongo::Client.
192
+ ** Mongo::Client インスタンス.
167
193
 
168
194
  === ドキュメントの機能を取り入れる.
169
195
 
@@ -172,15 +198,41 @@ Mongous.connect( hosts_or_uri = nil, **opts )
172
198
  include Mongous::Document
173
199
  ----
174
200
 
201
+ === 別のデータベースを割り当てる.
202
+
203
+ [source,ruby]
204
+ ----
205
+ self.client=( client )
206
+ ----
207
+
208
+ * Result:
209
+ ** Mongo::Client インスタンス.
210
+
211
+ * Parameter:
212
+ ** client: Mongo::Client インスタンス.
213
+
214
+ === 別のコレクションを割り当てる.
215
+
216
+ [source,ruby]
217
+ ----
218
+ self.collection_name=( collection_name )
219
+ ----
220
+
221
+ * Result:
222
+ ** Collection name 文字列.
223
+
224
+ * Parameter:
225
+ ** collection_name: コレクション名.
226
+
175
227
  === ドキュメントの要素を定義する.
176
228
 
177
229
  [source,ruby]
178
230
  ----
179
- field( label, *attrs, &block )
231
+ field( symbol, *attrs, **items )
180
232
  ----
181
233
 
182
234
  * Parameter:
183
- ** label: 項目名シンボル
235
+ ** symbol: 項目名
184
236
  ** attrs: 項目属性
185
237
  *** Class: 項目検証用 Class
186
238
  *** Proc: 項目検証用 Proc
@@ -188,17 +240,20 @@ field( label, *attrs, &block )
188
240
  *** Array: 項目検証用配列
189
241
  *** Symbol: 特別な指示子
190
242
  **** must: ナル値でも空文字列でもない
191
- ** block: デフォルト値を返す
243
+ ** items: 保存時の操作.
244
+ *** default: 未定義のときの値または Proc.
245
+ *** create: ドキュメントを新規保存するときの値または Proc.
246
+ *** update: ドキュメントを更新するときの値または Proc.
192
247
 
193
248
  === 保存や代入の前にドキュメントの要素を検証する.
194
249
 
195
250
  [source,ruby]
196
251
  ----
197
- verify( *syms, &block )
252
+ verify( *directives, &block )
198
253
  ----
199
254
 
200
255
  * Parameter:
201
- ** syms: 条件シンボル
256
+ ** directives: 条件シンボル
202
257
  *** strict: 定義済み項目名であることを検証する.
203
258
  ** block: 各項目値を検証して真偽を返す内容を記述する.
204
259
 
@@ -206,12 +261,12 @@ verify( *syms, &block )
206
261
 
207
262
  [source,ruby]
208
263
  ----
209
- index( *syms, **opts )
264
+ index( *symbols, **options )
210
265
  ----
211
266
 
212
267
  * Parameter:
213
- ** syms: 項目名シンボル
214
- ** opts: Mongo::Collection#indexes() のオプション.
268
+ ** symbols: 項目名
269
+ ** options: Mongo::Collection#indexes() のオプション.
215
270
 
216
271
  === 項目値がナル値でも空文字列でもないことを検証する.
217
272
 
@@ -226,6 +281,70 @@ having?( label )
226
281
  * Parameter:
227
282
  ** label: メソッド呼び出しする項目名.
228
283
 
284
+ === 検索条件に名前をつける.
285
+
286
+ [source,ruby]
287
+ ----
288
+ filter( symbol, filter_or_cond )
289
+ ----
290
+
291
+ * Parameter:
292
+ ** symbol: 項目名
293
+ ** filter_or_cond: フィルタまたは検索条件
294
+
295
+ === 検索条件.
296
+
297
+ [source,ruby]
298
+ ----
299
+ where( filter = nil, **conditions )
300
+ ----
301
+
302
+ * Result:
303
+ ** Filter instance.
304
+
305
+ * Parameter:
306
+ ** filter: 項目名またはフィルタインスタンス
307
+ ** conditions: 検索条件
308
+
309
+ === 否定検索条件.
310
+
311
+ [source,ruby]
312
+ ----
313
+ not( filter = nil, **conditions )
314
+ ----
315
+
316
+ * Result:
317
+ ** Filter instance.
318
+
319
+ * Parameter:
320
+ ** filter: 項目名またはフィルタインスタンス
321
+ ** conditions: 検索条件
322
+
323
+ === 論理積検索条件.
324
+
325
+ [source,ruby]
326
+ ----
327
+ and( *filters )
328
+ ----
329
+
330
+ * Result:
331
+ ** Filter instance.
332
+
333
+ * Parameter:
334
+ ** filters: 項目名またはフィルタインスタンス
335
+
336
+ === 論理和検索条件.
337
+
338
+ [source,ruby]
339
+ ----
340
+ or( *filters )
341
+ ----
342
+
343
+ * Result:
344
+ ** Filter instance.
345
+
346
+ * Parameter:
347
+ ** filters: 項目名またはフィルタインスタンス
229
348
 
230
349
  == 貢献
231
350