mongous 0.2.1 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +73 -0
  3. data/README.adoc +176 -26
  4. data/README.ja.adoc +176 -26
  5. data/Rakefile +8 -8
  6. data/_Gemfile.lock +38 -0
  7. data/lib/mongous/base.rb +52 -8
  8. data/lib/mongous/document.rb +21 -10
  9. data/lib/mongous/extention.rb +45 -35
  10. data/lib/mongous/filter.rb +316 -230
  11. data/lib/mongous/version.rb +1 -1
  12. data/mongous.gemspec +4 -4
  13. data/sample/connect_auto_0.rb +9 -0
  14. data/sample/declare_compact_1.rb +5 -8
  15. data/sample/declare_compact_2.rb +38 -0
  16. data/sample/declare_label_1.rb +7 -7
  17. data/sample/declare_ndex_1.rb +6 -6
  18. data/sample/declare_ndex_2.rb +7 -7
  19. data/sample/declare_strict_1.rb +2 -4
  20. data/sample/declare_strict_2.rb +2 -4
  21. data/sample/multi_collection_1.rb +0 -2
  22. data/sample/multi_collection_2.rb +0 -2
  23. data/sample/multi_collection_3.rb +24 -0
  24. data/sample/query_basic_1.rb +10 -4
  25. data/sample/query_basic_2.rb +10 -4
  26. data/sample/query_basic_3.rb +0 -2
  27. data/sample/query_basic_4.rb +0 -2
  28. data/sample/query_basic_5.rb +0 -2
  29. data/sample/query_basic_6.rb +56 -0
  30. data/sample/query_detail_1.rb +2 -3
  31. data/sample/query_detail_2.rb +2 -3
  32. data/sample/query_detail_3.rb +0 -2
  33. data/sample/query_filter_1.rb +0 -2
  34. data/sample/query_filter_2.rb +0 -2
  35. data/sample/query_find_1.rb +14 -13
  36. data/sample/query_select_1.rb +54 -0
  37. data/sample/query_skip_limit_1.rb +17 -16
  38. data/sample/query_skip_limit_2.rb +19 -10
  39. data/sample/query_sort_1.rb +43 -0
  40. data/sample/save_basic_1.rb +1 -5
  41. data/sample/save_basic_2.rb +1 -5
  42. data/sample/save_basic_3.rb +1 -5
  43. data/sample/save_detail_1.rb +0 -2
  44. data/sample/save_detail_2.rb +0 -2
  45. data/sample/save_detail_3.rb +5 -7
  46. data/sample/save_verify_1.rb +2 -4
  47. data/sample/save_verify_2.rb +0 -2
  48. data/sample/save_verify_3.rb +0 -2
  49. data/sample/save_verify_4.rb +0 -2
  50. data/sample/save_verify_5.rb +0 -2
  51. data/sample/save_verify_6.rb +0 -2
  52. data/sample/save_verify_7.rb +0 -2
  53. data/sample/update_basic_1.rb +1 -5
  54. data/sample/zap_basic_1.rb +1 -5
  55. data/sample/zap_basic_2.rb +2 -6
  56. data/sample/zap_basic_3.rb +7 -0
  57. data/sample/zbenchmark_search_1.rb +114 -0
  58. data/sample/zbenchmark_search_2.rb +114 -0
  59. data/sample/zbenchmark_search_3.rb +88 -0
  60. metadata +31 -22
  61. data/.travis.yml +0 -6
  62. data/sample/query_projection_1.rb +0 -41
  63. data/sample/query_sort_order_1.rb +0 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dded44fdc39ecb6ff4eeb6db10183e3a940f19317062a73d85ecf4d4c6e10437
4
- data.tar.gz: 34fa872a88fdc0aac33101465a490fb71f9132542e7f4583f86313527c532d9b
3
+ metadata.gz: 6fec2b64e882095a188352b441075601ca5e84ba7063d70a04e7d182533ebb34
4
+ data.tar.gz: b332b82c2d95dab25b3c69c1786757e17c0c599319f88defacad44303f8d828c
5
5
  SHA512:
6
- metadata.gz: 1b39238447cf6419f663b22563930a5e32671983e29395bfc31dabeaf77d1dfca3ff7dbd84e54b8e231c9f8810729c2701d491b7ae9e3e8171eda400a97bf041
7
- data.tar.gz: 7660804d5e3452714dbcbe0ac30a532789dbc553f3e5929ec58d4f0dfafd4bb9bd4dc0cb8aa124265c9af6dd6ac25acfc1361b4fa239317fc2a5bde26eb2e932
6
+ metadata.gz: 6cb477d1f25353cecc88f333136840ed75880b2ab38e7825f6053c01134f7bb5aa24950777a626cd46cc93e2fc88a857a1093f7cf925362e524bd857f6eb794b
7
+ data.tar.gz: d8ee46a451a09ab429b9754e861f21e276d311cb6b6467faef093f79a4e4868881cbc0dfe7679aa5205b5838c2ca93d1d7ff48150cc12226a0efa8ff8d5e27d5
@@ -0,0 +1,73 @@
1
+
2
+ AllCops:
3
+ Exclude:
4
+ - '.*'
5
+ - '*'
6
+ - '*.gemspec'
7
+ - 'Gemfile*'
8
+ - 'bin/**'
9
+ - 'exe/**'
10
+ - 'config/**/*'
11
+ - 'spec/**/*'
12
+ - 'tmp/**/*'
13
+ - 'vendor/**/*'
14
+ TargetRubyVersion: 2.7
15
+
16
+ Layout/ExtraSpacing:
17
+ Enabled: false
18
+
19
+ Layout/SpaceAroundOperators:
20
+ Enabled: false
21
+
22
+ Layout/SpaceBeforeFirstArg:
23
+ Enabled: false
24
+
25
+ Layout/SpaceInsideParens:
26
+ Enabled: false
27
+
28
+ Layout/SpaceInsideArrayLiteralBrackets:
29
+ Enabled: false
30
+
31
+ Layout/SpaceInsideRangeLiteral:
32
+ Enabled: false
33
+
34
+ Layout/SpaceInsideReferenceBrackets:
35
+ Enabled: false
36
+
37
+ Layout/SpaceInsideStringInterpolation:
38
+ Enabled: false
39
+
40
+ Lint/AmbiguousBlockAssociation:
41
+ Enabled: false
42
+
43
+ Lint/EmptyWhen:
44
+ Enabled: false
45
+
46
+ Lint/ReturnInVoidContext:
47
+ Enabled: false
48
+
49
+ Lint/UselessAssignment:
50
+ Enabled: false
51
+
52
+ Metrics/BlockLength:
53
+ Enabled: false
54
+
55
+ Metrics/LineLength:
56
+ Enabled: false
57
+ Max: 120
58
+
59
+ Metrics/MethodLength:
60
+ Enabled: false
61
+
62
+ Style/Documentation:
63
+ Enabled: true
64
+
65
+ Style/FrozenStringLiteralComment:
66
+ Enabled: false
67
+
68
+ Style/NumericPredicate:
69
+ Enabled: false
70
+
71
+ Style/StringLiterals:
72
+ Enabled: false
73
+
@@ -9,8 +9,8 @@ Yet another mongo wrapper library.
9
9
  * Check if the constraint conditions are met when saving the document.
10
10
  * Check if the constraint condition is satisfied when setting the item value of the document.
11
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.
12
+ * Item contents at the time of document creation and update can be described by value or Proc.
13
+ * The database collection name corresponding to the class name is not converted to the plural form.
14
14
 
15
15
  == Installation
16
16
 
@@ -39,11 +39,7 @@ Or install it yourself as:
39
39
  ----
40
40
  require "mongous"
41
41
 
42
- Mongous.connect!
43
-
44
- class Book
45
- include Mongous::Document
46
- end
42
+ Mongous.document! :Book
47
43
  ----
48
44
 
49
45
  === Detail declaration
@@ -57,10 +53,10 @@ Mongous.connect! ["localhost:27017"], database: "test"
57
53
  class Book
58
54
  include Mongous::Document
59
55
 
60
- field :title, String, :must
56
+ field :title, String, :must
61
57
  field :author, String
62
58
  field :publisher, String
63
- field :style, String, %w[hardcover, softcover, paperback]
59
+ field :style, String, %w[hardcover softcover paperback]
64
60
  field :size, String, /[AB]\d/
65
61
  field :price, Integer, (0..1_000_000)
66
62
  field :page, Integer, proc{ page % 4 == 0 }
@@ -107,7 +103,8 @@ Book.create( **doc )
107
103
  ----
108
104
  pp books = Book.all
109
105
 
110
- p book = Book.where( title: "title 1" ).first
106
+ p book = Book.where( title: /title/ ).first
107
+ p book = Book.where( title: /title/ ).last
111
108
 
112
109
  books = Book.where( title: /title/ ).all
113
110
  books.each do |book|
@@ -141,7 +138,15 @@ Book.find( { title: /title/ }, { projection: {_id: 0} } ).each do |book|
141
138
  p book
142
139
  end
143
140
 
144
- pp Book.where( title: /title/ )[0, 5].all
141
+ Book.where( title: /title/ ).select( _id: 0 ).each do |book|
142
+ p book
143
+ end
144
+
145
+ Book.select( _id: 0 )[0, 5].each do |book|
146
+ p book
147
+ end
148
+
149
+ pp Book.select( :title, :price, :size )[5, 5].all
145
150
  ----
146
151
 
147
152
  === Update document
@@ -191,7 +196,22 @@ Mongous.connect( hosts_or_uri = nil, **options )
191
196
  * Result:
192
197
  ** Mongo::Client instance.
193
198
 
194
- === Include document functions.
199
+ === Define collection operate class with default settings.
200
+
201
+ [source,ruby]
202
+ ----
203
+ Mongous.document!( *names, **options )
204
+ ----
205
+
206
+ * Result:
207
+ ** nil.
208
+
209
+ * Parameter:
210
+ ** names: Collection names. (String or Symbol)
211
+ ** options: Options.
212
+ *** timestamp: If true then add fields :created_at, :updated_at.
213
+
214
+ === Include document functions into collection operate class.
195
215
 
196
216
  [source,ruby]
197
217
  ----
@@ -202,7 +222,7 @@ include Mongous::Document
202
222
 
203
223
  [source,ruby]
204
224
  ----
205
- self.client=( _client )
225
+ self.client=( client )
206
226
  ----
207
227
 
208
228
  * Result:
@@ -211,6 +231,19 @@ self.client=( _client )
211
231
  * Parameter:
212
232
  ** client: Mongo::Client instance.
213
233
 
234
+ === Get binded database.
235
+
236
+ [source,ruby]
237
+ ----
238
+ self.client
239
+ ----
240
+
241
+ * Result:
242
+ ** Mongo::Client instance.
243
+
244
+ * Parameter:
245
+ ** None.
246
+
214
247
  === Bind another collection.
215
248
 
216
249
  [source,ruby]
@@ -224,11 +257,37 @@ self.collection_name=( _collection_name )
224
257
  * Parameter:
225
258
  ** collection_name: Collection name.
226
259
 
260
+ === Get binded collection name.
261
+
262
+ [source,ruby]
263
+ ----
264
+ self.collection_name
265
+ ----
266
+
267
+ * Result:
268
+ ** Collection name string.
269
+
270
+ * Parameter:
271
+ ** None.
272
+
273
+ === Get collection.
274
+
275
+ [source,ruby]
276
+ ----
277
+ self.collection( collection_name = nil )
278
+ ----
279
+
280
+ * Result:
281
+ ** Mongo::Collection instance.
282
+
283
+ * Parameter:
284
+ ** collection_name: Tempolary collection name.
285
+
227
286
  === Declare document structure.
228
287
 
229
288
  [source,ruby]
230
289
  ----
231
- field( symbol, *attrs, **items )
290
+ self.field( symbol, *attrs, **items )
232
291
  ----
233
292
 
234
293
  * Parameter:
@@ -249,7 +308,7 @@ field( symbol, *attrs, **items )
249
308
 
250
309
  [source,ruby]
251
310
  ----
252
- verify( *directives, &block )
311
+ self.verify( *directives, &block )
253
312
  ----
254
313
 
255
314
  * Parameter:
@@ -261,7 +320,7 @@ verify( *directives, &block )
261
320
 
262
321
  [source,ruby]
263
322
  ----
264
- index( *symbols, **options )
323
+ self.index( *symbols, **options )
265
324
  ----
266
325
 
267
326
  * Parameter:
@@ -272,7 +331,7 @@ index( *symbols, **options )
272
331
 
273
332
  [source,ruby]
274
333
  ----
275
- having?( label )
334
+ self.having?( label )
276
335
  ----
277
336
 
278
337
  * Result:
@@ -285,22 +344,38 @@ having?( label )
285
344
 
286
345
  [source,ruby]
287
346
  ----
288
- filter( symbol, filter_or_cond )
347
+ self.filter( symbol, filter_or_cond )
289
348
  ----
290
349
 
291
350
  * Parameter:
292
351
  ** symbol: Filter name.
293
352
  ** filter_or_cond: Filter or search criteria.
294
353
 
354
+ === Select output fields.
355
+
356
+ [source,ruby]
357
+ ----
358
+ Mongous::Document.select( *keys, **kwargs )
359
+ Mongous::Filter#select( *keys, **kwargs )
360
+ ----
361
+
362
+ * Result:
363
+ ** Mongous::Filter instance.
364
+
365
+ * Parameter:
366
+ ** keys: Field symbols.
367
+ ** kwargs: Field symbols and values.
368
+
295
369
  === Search condition.
296
370
 
297
371
  [source,ruby]
298
372
  ----
299
- where( filter = nil, **conditions )
373
+ Mongous::Document.where( filter = nil, **conditions )
374
+ Mongous::Filter#where( filter = nil, **conditions )
300
375
  ----
301
376
 
302
377
  * Result:
303
- ** Filter instance.
378
+ ** Mongous::Filter instance.
304
379
 
305
380
  * Parameter:
306
381
  ** filter: Filter name symbol, or filter instance.
@@ -310,11 +385,12 @@ where( filter = nil, **conditions )
310
385
 
311
386
  [source,ruby]
312
387
  ----
313
- not( filter = nil, **conditions )
388
+ Mongous::Document.not( filter = nil, **conditions )
389
+ Mongous::Filter#not( filter = nil, **conditions )
314
390
  ----
315
391
 
316
392
  * Result:
317
- ** Filter instance.
393
+ ** Mongous::Filter instance.
318
394
 
319
395
  * Parameter:
320
396
  ** filter: Filter name symbol, or filter instance.
@@ -324,11 +400,12 @@ not( filter = nil, **conditions )
324
400
 
325
401
  [source,ruby]
326
402
  ----
327
- and( *filters )
403
+ Mongous::Document.and( *filters )
404
+ Mongous::Filter#and( *filters )
328
405
  ----
329
406
 
330
407
  * Result:
331
- ** Filter instance.
408
+ ** Mongous::Filter instance.
332
409
 
333
410
  * Parameter:
334
411
  ** filters: Filter name symbol, or filter instance.
@@ -337,15 +414,88 @@ and( *filters )
337
414
 
338
415
  [source,ruby]
339
416
  ----
340
- or( *filters )
417
+ Mongous::Document.or( *filters )
418
+ Mongous::Filter#or( *filters )
341
419
  ----
342
420
 
343
421
  * Result:
344
- ** Filter instance.
422
+ ** Mongous::Filter instance.
345
423
 
346
424
  * Parameter:
347
425
  ** filters: Field name symbol, or filter instance.
348
426
 
427
+ === Create document.
428
+
429
+ [source,ruby]
430
+ ----
431
+ Mongous::Document.create( **doc )
432
+ ----
433
+
434
+ * Result:
435
+ ** nil.
436
+
437
+ * Parameter:
438
+ ** doc: Keyword arguments.
439
+
440
+ === Save document.
441
+
442
+ [source,ruby]
443
+ ----
444
+ Mongous::Document#save
445
+ ----
446
+
447
+ * Result:
448
+ ** nil.
449
+
450
+ === Convert document to Hash.
451
+
452
+ [source,ruby]
453
+ ----
454
+ Mongous::Document#to_hash
455
+ ----
456
+
457
+ * Result:
458
+ ** Hash object.
459
+
460
+ === Convert document to JSON.
461
+
462
+ [source,ruby]
463
+ ----
464
+ Mongous::Document#to_json
465
+ ----
466
+
467
+ * Result:
468
+ ** JSON String.
469
+
470
+ === Read document field.
471
+
472
+ [source,ruby]
473
+ ----
474
+ Mongous::Document#[]( field_name )
475
+ Mongous::Document#field_name
476
+ ----
477
+
478
+ * Result:
479
+ ** field_value.
480
+
481
+ * Parameter:
482
+ ** field_name: Field name.
483
+
484
+ === Write document field.
485
+
486
+ [source,ruby]
487
+ ----
488
+ Mongous::Document#[]=( field_name, field_value )
489
+ Mongous::Document#field_name = field_value
490
+ ----
491
+
492
+ * Result:
493
+ ** field_value.
494
+
495
+ * Parameter:
496
+ ** field_name: Field name.
497
+ ** field_value: Field value.
498
+
349
499
  == Contributing
350
500
 
351
501
  Bug reports and pull requests are welcome on GitHub at https://github.com/arimay/mongous.
@@ -4,13 +4,13 @@
4
4
 
5
5
  == 特徴
6
6
 
7
- * 組込みと標準添付を除いて、mongo driver と bson のみに依存する軽いライブラリである。
7
+ * 組込みと標準添付を除いて、mongo driver と bson のみに依存する軽いライブラリである.
8
8
  * ドキュメント項目の制約条件を Array, Range, Regexp, Proc インスタンスまたは基本クラスで記述できる.
9
9
  * ドキュメント保存時に制約条件を満たすか検査する.
10
10
  * ドキュメントの項目値設定時に制約条件を満たすか検査する.
11
11
  * ドキュメントの未定義項目の内容を値または Proc で記述できる.
12
- * ドキュメントの作成時に項目設定内容を値または Proc で記述できる.
13
- * ドキュメントの更新時に項目設定内容を値または Proc で記述できる.
12
+ * ドキュメント作成時および更新時の項目内容を値または Proc で記述できる.
13
+ * クラス名に対応するデータベースのコレクション名は、複数形へ変換しない.
14
14
 
15
15
  == 導入
16
16
 
@@ -33,17 +33,13 @@ gem 'mongous'
33
33
 
34
34
  == 使い方
35
35
 
36
- === 簡素な定義
36
+ === 簡潔な定義
37
37
 
38
38
  [source,ruby]
39
39
  ----
40
40
  require "mongous"
41
41
 
42
- Mongous.connect!
43
-
44
- class Book
45
- include Mongous::Document
46
- end
42
+ Mongous.document! :Book
47
43
  ----
48
44
 
49
45
  === 詳細な定義
@@ -60,7 +56,7 @@ class Book
60
56
  field :title, String, :must
61
57
  field :author, String
62
58
  field :publisher, String
63
- field :style, String, %w[hardcover, softcover, paperback]
59
+ field :style, String, %w[hardcover softcover paperback]
64
60
  field :size, String, /[AB]\d/
65
61
  field :price, Integer, (0..1_000_000)
66
62
  field :page, Integer, proc{ page % 4 == 0 }
@@ -107,7 +103,8 @@ Book.create( **doc )
107
103
  ----
108
104
  pp books = Book.all
109
105
 
110
- p book = Book.where( title: "title 1" ).first
106
+ p book = Book.where( title: /title/ ).first
107
+ p book = Book.where( title: /title/ ).last
111
108
 
112
109
  books = Book.where( title: /title/ ).all
113
110
  books.each do |book|
@@ -141,7 +138,15 @@ Book.find( { title: /title/ }, { projection: {_id: 0} } ).each do |book|
141
138
  p book
142
139
  end
143
140
 
144
- pp Book.where( title: /title/ )[0, 5].all
141
+ Book.where( title: /title/ ).select( _id: 0 ).each do |book|
142
+ p book
143
+ end
144
+
145
+ Book.select( _id: 0 )[0, 5].each do |book|
146
+ p book
147
+ end
148
+
149
+ pp Book.select( :title, :price, :size )[5, 5].all
145
150
  ----
146
151
 
147
152
  === ドキュメント更新
@@ -191,7 +196,22 @@ Mongous.connect( hosts_or_uri = nil, **options )
191
196
  * Result:
192
197
  ** Mongo::Client インスタンス.
193
198
 
194
- === ドキュメントの機能を取り入れる.
199
+ === コレクション操作クラスをデフォルト設定で定義する.
200
+
201
+ [source,ruby]
202
+ ----
203
+ Mongous.document!( *names, **options )
204
+ ----
205
+
206
+ * Result:
207
+ ** nil.
208
+
209
+ * Parameter:
210
+ ** names: コレクション名. (String または Symbol)
211
+ ** options: オプション
212
+ *** timestamp: 真のとき, フィールド :created_at, :updated_at を追加する.
213
+
214
+ === コレクション操作クラスにドキュメントの機能を取り入れる.
195
215
 
196
216
  [source,ruby]
197
217
  ----
@@ -211,6 +231,19 @@ self.client=( client )
211
231
  * Parameter:
212
232
  ** client: Mongo::Client インスタンス.
213
233
 
234
+ === Get binded database.
235
+
236
+ [source,ruby]
237
+ ----
238
+ self.client
239
+ ----
240
+
241
+ * Result:
242
+ ** Mongo::Client インスタンス.
243
+
244
+ * Parameter:
245
+ ** None.
246
+
214
247
  === 別のコレクションを割り当てる.
215
248
 
216
249
  [source,ruby]
@@ -224,11 +257,37 @@ self.collection_name=( collection_name )
224
257
  * Parameter:
225
258
  ** collection_name: コレクション名.
226
259
 
260
+ === Get binded collection name.
261
+
262
+ [source,ruby]
263
+ ----
264
+ self.collection_name
265
+ ----
266
+
267
+ * Result:
268
+ ** Collection name 文字列.
269
+
270
+ * Parameter:
271
+ ** None.
272
+
273
+ === Get collection.
274
+
275
+ [source,ruby]
276
+ ----
277
+ self.collection( collection_name = nil )
278
+ ----
279
+
280
+ * Result:
281
+ ** Mongo::Collection インスタンス.
282
+
283
+ * Parameter:
284
+ ** collection_name: 一時指定するコレクション名.
285
+
227
286
  === ドキュメントの要素を定義する.
228
287
 
229
288
  [source,ruby]
230
289
  ----
231
- field( symbol, *attrs, **items )
290
+ self.field( symbol, *attrs, **items )
232
291
  ----
233
292
 
234
293
  * Parameter:
@@ -249,7 +308,7 @@ field( symbol, *attrs, **items )
249
308
 
250
309
  [source,ruby]
251
310
  ----
252
- verify( *directives, &block )
311
+ self.verify( *directives, &block )
253
312
  ----
254
313
 
255
314
  * Parameter:
@@ -261,7 +320,7 @@ verify( *directives, &block )
261
320
 
262
321
  [source,ruby]
263
322
  ----
264
- index( *symbols, **options )
323
+ self.index( *symbols, **options )
265
324
  ----
266
325
 
267
326
  * Parameter:
@@ -272,7 +331,7 @@ index( *symbols, **options )
272
331
 
273
332
  [source,ruby]
274
333
  ----
275
- having?( label )
334
+ self.having?( label )
276
335
  ----
277
336
 
278
337
  * Result:
@@ -285,22 +344,38 @@ having?( label )
285
344
 
286
345
  [source,ruby]
287
346
  ----
288
- filter( symbol, filter_or_cond )
347
+ self.filter( symbol, filter_or_cond )
289
348
  ----
290
349
 
291
350
  * Parameter:
292
351
  ** symbol: 項目名
293
352
  ** filter_or_cond: フィルタまたは検索条件
294
353
 
354
+ === 出力項目を選択する.
355
+
356
+ [source,ruby]
357
+ ----
358
+ Mongous::Document.select( *keys, **kwargs )
359
+ Mongous::Filter#select( *keys, **kwargs )
360
+ ----
361
+
362
+ * Result:
363
+ ** Mongous::Filter instance.
364
+
365
+ * Parameter:
366
+ ** keys: 項目名
367
+ ** kwargs: 項目名と項目値.
368
+
295
369
  === 検索条件.
296
370
 
297
371
  [source,ruby]
298
372
  ----
299
- where( filter = nil, **conditions )
373
+ Mongous::Document.where( filter = nil, **conditions )
374
+ Mongous::Filter#where( filter = nil, **conditions )
300
375
  ----
301
376
 
302
377
  * Result:
303
- ** Filter instance.
378
+ ** Mongous::Filter instance.
304
379
 
305
380
  * Parameter:
306
381
  ** filter: 項目名またはフィルタインスタンス
@@ -310,11 +385,12 @@ where( filter = nil, **conditions )
310
385
 
311
386
  [source,ruby]
312
387
  ----
313
- not( filter = nil, **conditions )
388
+ Mongous::Document.not( filter = nil, **conditions )
389
+ Mongous::Filter#not( filter = nil, **conditions )
314
390
  ----
315
391
 
316
392
  * Result:
317
- ** Filter instance.
393
+ ** Mongous::Filter instance.
318
394
 
319
395
  * Parameter:
320
396
  ** filter: 項目名またはフィルタインスタンス
@@ -324,11 +400,12 @@ not( filter = nil, **conditions )
324
400
 
325
401
  [source,ruby]
326
402
  ----
327
- and( *filters )
403
+ Mongous::Document.and( *filters )
404
+ Mongous::Filter#and( *filters )
328
405
  ----
329
406
 
330
407
  * Result:
331
- ** Filter instance.
408
+ ** Mongous::Filter instance.
332
409
 
333
410
  * Parameter:
334
411
  ** filters: 項目名またはフィルタインスタンス
@@ -337,15 +414,88 @@ and( *filters )
337
414
 
338
415
  [source,ruby]
339
416
  ----
340
- or( *filters )
417
+ Mongous::Document.or( *filters )
418
+ Mongous::Filter#or( *filters )
341
419
  ----
342
420
 
343
421
  * Result:
344
- ** Filter instance.
422
+ ** Mongous::Filter instance.
345
423
 
346
424
  * Parameter:
347
425
  ** filters: 項目名またはフィルタインスタンス
348
426
 
427
+ === ドキュメントを作成.
428
+
429
+ [source,ruby]
430
+ ----
431
+ Mongous::Document.create( **doc )
432
+ ----
433
+
434
+ * Result:
435
+ ** nil.
436
+
437
+ * Parameter:
438
+ ** doc: キーワード引数.
439
+
440
+ === ドキュメントを保存.
441
+
442
+ [source,ruby]
443
+ ----
444
+ Mongous::Document#save
445
+ ----
446
+
447
+ * Result:
448
+ ** nil.
449
+
450
+ === ドキュメントをHashに変換.
451
+
452
+ [source,ruby]
453
+ ----
454
+ Mongous::Document#to_hash
455
+ ----
456
+
457
+ * Result:
458
+ ** Hash object.
459
+
460
+ === ドキュメントをJSONに変換.
461
+
462
+ [source,ruby]
463
+ ----
464
+ Mongous::Document#to_json
465
+ ----
466
+
467
+ * Result:
468
+ ** JSON String.
469
+
470
+ === ドキュメントの項目値を読む.
471
+
472
+ [source,ruby]
473
+ ----
474
+ Mongous::Document#[]( field_name )
475
+ Mongous::Document#field_name
476
+ ----
477
+
478
+ * Result:
479
+ ** 項目値.
480
+
481
+ * Parameter:
482
+ ** field_name: 項目名.
483
+
484
+ === ドキュメントの項目値を書く.
485
+
486
+ [source,ruby]
487
+ ----
488
+ Mongous::Document#[]=( field_name, field_value )
489
+ Mongous::Document#field_name = field_value
490
+ ----
491
+
492
+ * Result:
493
+ ** 項目値.
494
+
495
+ * Parameter:
496
+ ** field_name: 項目名.
497
+ ** field_value: 項目値.
498
+
349
499
  == 貢献
350
500
 
351
501
  不具合報告とプルリクエストは GitHub https://github.com/arimay/mongous まで.