mongous 0.3.0 → 0.4.0

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: e316aaf87661c4fe27054cdbaef39ba7f21f24432b3752ffb1cb308894de5272
4
- data.tar.gz: 5597f0a55efc8d1afa45e6bf9ee93ea77653d7161d12e776bc979a6543b2c94a
3
+ metadata.gz: bf1d2cbfd528ed1a623833025cf965b5200a1f973ce1200609ae459e6167694f
4
+ data.tar.gz: 785aea052055755ec01bab88f47da0915371546d9c84f14a7876f968c79a5e3d
5
5
  SHA512:
6
- metadata.gz: 4dc7ea514d20c8fc9ed8eaed86b4feb293df3e713a1db3acb60eb46abd61f28f0dbeeb9a68b9ac1442b6b690b3e4b12653bce102d007d912e6c08a700bd964ef
7
- data.tar.gz: 44cfdfa61226dbfcaa40d846bfa2f00a76137b297141cbf4ea7318abdcc999271cddafd9e65bc5ea5d69745674da87aa719c2b34968d40968762d3f9e0855ced
6
+ metadata.gz: 706bcfdac572ee3864a70d47101a689142134f030f20c37123e33f64575bd046eea74a656bdce29487f93c441a4374d77b97e96989fd234940daaf81171ace19
7
+ data.tar.gz: e4c1f4dae468a78f376b2a89a612a7f419e39939b0b486451980857e24127e0420e2fb2dc13f8afe8a7e1cb6686a5c2c82ce3e1b6a7dc94609327f258a785d12
@@ -38,7 +38,6 @@ Or install it yourself as:
38
38
  ----
39
39
  require "mongous"
40
40
 
41
- Mongous.connect!
42
41
  Mongous.attach! :Book
43
42
  ----
44
43
 
@@ -137,7 +136,15 @@ Book.find( { title: /title/ }, { projection: {_id: 0} } ).each do |book|
137
136
  p book
138
137
  end
139
138
 
140
- pp Book.where( title: /title/ )[0, 5].all
139
+ Book.where( title: /title/ ).select( _id: 0 ).each do |book|
140
+ p book
141
+ end
142
+
143
+ Book.select( _id: 0 )[0, 5].each do |book|
144
+ p book
145
+ end
146
+
147
+ pp Book.select( :title, :price, :size )[5, 5].all
141
148
  ----
142
149
 
143
150
  === Update document
@@ -211,7 +218,7 @@ include Mongous::Document
211
218
 
212
219
  [source,ruby]
213
220
  ----
214
- self.client=( _client )
221
+ self.client=( client )
215
222
  ----
216
223
 
217
224
  * Result:
@@ -220,6 +227,19 @@ self.client=( _client )
220
227
  * Parameter:
221
228
  ** client: Mongo::Client instance.
222
229
 
230
+ === Get binded database.
231
+
232
+ [source,ruby]
233
+ ----
234
+ self.client
235
+ ----
236
+
237
+ * Result:
238
+ ** Mongo::Client instance.
239
+
240
+ * Parameter:
241
+ ** None.
242
+
223
243
  === Bind another collection.
224
244
 
225
245
  [source,ruby]
@@ -233,11 +253,37 @@ self.collection_name=( _collection_name )
233
253
  * Parameter:
234
254
  ** collection_name: Collection name.
235
255
 
256
+ === Get binded collection name.
257
+
258
+ [source,ruby]
259
+ ----
260
+ self.collection_name
261
+ ----
262
+
263
+ * Result:
264
+ ** Collection name string.
265
+
266
+ * Parameter:
267
+ ** None.
268
+
269
+ === Get collection.
270
+
271
+ [source,ruby]
272
+ ----
273
+ self.collection( collection_name = nil )
274
+ ----
275
+
276
+ * Result:
277
+ ** Mongo::Collection instance.
278
+
279
+ * Parameter:
280
+ ** collection_name: Tempolary collection name.
281
+
236
282
  === Declare document structure.
237
283
 
238
284
  [source,ruby]
239
285
  ----
240
- field( symbol, *attrs, **items )
286
+ self.field( symbol, *attrs, **items )
241
287
  ----
242
288
 
243
289
  * Parameter:
@@ -258,7 +304,7 @@ field( symbol, *attrs, **items )
258
304
 
259
305
  [source,ruby]
260
306
  ----
261
- verify( *directives, &block )
307
+ self.verify( *directives, &block )
262
308
  ----
263
309
 
264
310
  * Parameter:
@@ -270,7 +316,7 @@ verify( *directives, &block )
270
316
 
271
317
  [source,ruby]
272
318
  ----
273
- index( *symbols, **options )
319
+ self.index( *symbols, **options )
274
320
  ----
275
321
 
276
322
  * Parameter:
@@ -281,7 +327,7 @@ index( *symbols, **options )
281
327
 
282
328
  [source,ruby]
283
329
  ----
284
- having?( label )
330
+ self.having?( label )
285
331
  ----
286
332
 
287
333
  * Result:
@@ -294,22 +340,38 @@ having?( label )
294
340
 
295
341
  [source,ruby]
296
342
  ----
297
- filter( symbol, filter_or_cond )
343
+ self.filter( symbol, filter_or_cond )
298
344
  ----
299
345
 
300
346
  * Parameter:
301
347
  ** symbol: Filter name.
302
348
  ** filter_or_cond: Filter or search criteria.
303
349
 
350
+ === Select output fields.
351
+
352
+ [source,ruby]
353
+ ----
354
+ Mongous::Document.select( *keys, **kwargs )
355
+ Mongous::Filter#select( *keys, **kwargs )
356
+ ----
357
+
358
+ * Result:
359
+ ** Mongous::Filter instance.
360
+
361
+ * Parameter:
362
+ ** keys: Field symbols.
363
+ ** kwargs: Field symbols and values.
364
+
304
365
  === Search condition.
305
366
 
306
367
  [source,ruby]
307
368
  ----
308
- Collection operate class #where( filter = nil, **conditions )
369
+ Mongous::Document.where( filter = nil, **conditions )
370
+ Mongous::Filter#where( filter = nil, **conditions )
309
371
  ----
310
372
 
311
373
  * Result:
312
- ** Filter instance.
374
+ ** Mongous::Filter instance.
313
375
 
314
376
  * Parameter:
315
377
  ** filter: Filter name symbol, or filter instance.
@@ -319,11 +381,12 @@ Collection operate class #where( filter = nil, **conditions )
319
381
 
320
382
  [source,ruby]
321
383
  ----
322
- Collection operate class #not( filter = nil, **conditions )
384
+ Mongous::Document.not( filter = nil, **conditions )
385
+ Mongous::Filter#not( filter = nil, **conditions )
323
386
  ----
324
387
 
325
388
  * Result:
326
- ** Filter instance.
389
+ ** Mongous::Filter instance.
327
390
 
328
391
  * Parameter:
329
392
  ** filter: Filter name symbol, or filter instance.
@@ -333,11 +396,12 @@ Collection operate class #not( filter = nil, **conditions )
333
396
 
334
397
  [source,ruby]
335
398
  ----
336
- Collection operate class #and( *filters )
399
+ Mongous::Document.and( *filters )
400
+ Mongous::Filter#and( *filters )
337
401
  ----
338
402
 
339
403
  * Result:
340
- ** Filter instance.
404
+ ** Mongous::Filter instance.
341
405
 
342
406
  * Parameter:
343
407
  ** filters: Filter name symbol, or filter instance.
@@ -346,20 +410,34 @@ Collection operate class #and( *filters )
346
410
 
347
411
  [source,ruby]
348
412
  ----
349
- Collection operate class #or( *filters )
413
+ Mongous::Document.or( *filters )
414
+ Mongous::Filter#or( *filters )
350
415
  ----
351
416
 
352
417
  * Result:
353
- ** Filter instance.
418
+ ** Mongous::Filter instance.
354
419
 
355
420
  * Parameter:
356
421
  ** filters: Field name symbol, or filter instance.
357
422
 
423
+ === Create document.
424
+
425
+ [source,ruby]
426
+ ----
427
+ Mongous::Document.create( **doc )
428
+ ----
429
+
430
+ * Result:
431
+ ** nil.
432
+
433
+ * Parameter:
434
+ ** doc: Keyword arguments.
435
+
358
436
  === Save document.
359
437
 
360
438
  [source,ruby]
361
439
  ----
362
- Document operate object #save
440
+ Mongous::Document#save
363
441
  ----
364
442
 
365
443
  * Result:
@@ -369,7 +447,7 @@ Document operate object #save
369
447
 
370
448
  [source,ruby]
371
449
  ----
372
- Document operate object #to_hash
450
+ Mongous::Document#to_hash
373
451
  ----
374
452
 
375
453
  * Result:
@@ -379,7 +457,7 @@ Document operate object #to_hash
379
457
 
380
458
  [source,ruby]
381
459
  ----
382
- Document operate object #to_hash
460
+ Mongous::Document#to_json
383
461
  ----
384
462
 
385
463
  * Result:
@@ -389,8 +467,8 @@ Document operate object #to_hash
389
467
 
390
468
  [source,ruby]
391
469
  ----
392
- Document operate object #[]( field_name )
393
- Document operate object #field_name
470
+ Mongous::Document#[]( field_name )
471
+ Mongous::Document#field_name
394
472
  ----
395
473
 
396
474
  * Result:
@@ -403,8 +481,8 @@ Document operate object #field_name
403
481
 
404
482
  [source,ruby]
405
483
  ----
406
- Document operate object #[]=( field_name, field_value )
407
- Document operate object #field_name = field_value
484
+ Mongous::Document#[]=( field_name, field_value )
485
+ Mongous::Document#field_name = field_value
408
486
  ----
409
487
 
410
488
  * Result:
@@ -38,7 +38,6 @@ gem 'mongous'
38
38
  ----
39
39
  require "mongous"
40
40
 
41
- Mongous.connect!
42
41
  Mongous.attach! :Book
43
42
  ----
44
43
 
@@ -137,7 +136,15 @@ Book.find( { title: /title/ }, { projection: {_id: 0} } ).each do |book|
137
136
  p book
138
137
  end
139
138
 
140
- pp Book.where( title: /title/ )[0, 5].all
139
+ Book.where( title: /title/ ).select( _id: 0 ).each do |book|
140
+ p book
141
+ end
142
+
143
+ Book.select( _id: 0 )[0, 5].each do |book|
144
+ p book
145
+ end
146
+
147
+ pp Book.select( :title, :price, :size )[5, 5].all
141
148
  ----
142
149
 
143
150
  === ドキュメント更新
@@ -220,6 +227,19 @@ self.client=( client )
220
227
  * Parameter:
221
228
  ** client: Mongo::Client インスタンス.
222
229
 
230
+ === Get binded database.
231
+
232
+ [source,ruby]
233
+ ----
234
+ self.client
235
+ ----
236
+
237
+ * Result:
238
+ ** Mongo::Client インスタンス.
239
+
240
+ * Parameter:
241
+ ** None.
242
+
223
243
  === 別のコレクションを割り当てる.
224
244
 
225
245
  [source,ruby]
@@ -233,11 +253,37 @@ self.collection_name=( collection_name )
233
253
  * Parameter:
234
254
  ** collection_name: コレクション名.
235
255
 
256
+ === Get binded collection name.
257
+
258
+ [source,ruby]
259
+ ----
260
+ self.collection_name
261
+ ----
262
+
263
+ * Result:
264
+ ** Collection name 文字列.
265
+
266
+ * Parameter:
267
+ ** None.
268
+
269
+ === Get collection.
270
+
271
+ [source,ruby]
272
+ ----
273
+ self.collection( collection_name = nil )
274
+ ----
275
+
276
+ * Result:
277
+ ** Mongo::Collection インスタンス.
278
+
279
+ * Parameter:
280
+ ** collection_name: 一時指定するコレクション名.
281
+
236
282
  === ドキュメントの要素を定義する.
237
283
 
238
284
  [source,ruby]
239
285
  ----
240
- field( symbol, *attrs, **items )
286
+ self.field( symbol, *attrs, **items )
241
287
  ----
242
288
 
243
289
  * Parameter:
@@ -258,7 +304,7 @@ field( symbol, *attrs, **items )
258
304
 
259
305
  [source,ruby]
260
306
  ----
261
- verify( *directives, &block )
307
+ self.verify( *directives, &block )
262
308
  ----
263
309
 
264
310
  * Parameter:
@@ -270,7 +316,7 @@ verify( *directives, &block )
270
316
 
271
317
  [source,ruby]
272
318
  ----
273
- index( *symbols, **options )
319
+ self.index( *symbols, **options )
274
320
  ----
275
321
 
276
322
  * Parameter:
@@ -281,7 +327,7 @@ index( *symbols, **options )
281
327
 
282
328
  [source,ruby]
283
329
  ----
284
- having?( label )
330
+ self.having?( label )
285
331
  ----
286
332
 
287
333
  * Result:
@@ -294,22 +340,38 @@ having?( label )
294
340
 
295
341
  [source,ruby]
296
342
  ----
297
- filter( symbol, filter_or_cond )
343
+ self.filter( symbol, filter_or_cond )
298
344
  ----
299
345
 
300
346
  * Parameter:
301
347
  ** symbol: 項目名
302
348
  ** filter_or_cond: フィルタまたは検索条件
303
349
 
350
+ === 出力項目を選択する.
351
+
352
+ [source,ruby]
353
+ ----
354
+ Mongous::Document.select( *keys, **kwargs )
355
+ Mongous::Filter#select( *keys, **kwargs )
356
+ ----
357
+
358
+ * Result:
359
+ ** Mongous::Filter instance.
360
+
361
+ * Parameter:
362
+ ** keys: 項目名
363
+ ** kwargs: 項目名と項目値.
364
+
304
365
  === 検索条件.
305
366
 
306
367
  [source,ruby]
307
368
  ----
308
- コレクション操作クラス #where( filter = nil, **conditions )
369
+ Mongous::Document.where( filter = nil, **conditions )
370
+ Mongous::Filter#where( filter = nil, **conditions )
309
371
  ----
310
372
 
311
373
  * Result:
312
- ** Filter instance.
374
+ ** Mongous::Filter instance.
313
375
 
314
376
  * Parameter:
315
377
  ** filter: 項目名またはフィルタインスタンス
@@ -319,11 +381,12 @@ filter( symbol, filter_or_cond )
319
381
 
320
382
  [source,ruby]
321
383
  ----
322
- コレクション操作クラス #not( filter = nil, **conditions )
384
+ Mongous::Document.not( filter = nil, **conditions )
385
+ Mongous::Filter#not( filter = nil, **conditions )
323
386
  ----
324
387
 
325
388
  * Result:
326
- ** Filter instance.
389
+ ** Mongous::Filter instance.
327
390
 
328
391
  * Parameter:
329
392
  ** filter: 項目名またはフィルタインスタンス
@@ -333,11 +396,12 @@ filter( symbol, filter_or_cond )
333
396
 
334
397
  [source,ruby]
335
398
  ----
336
- コレクション操作クラス #and( *filters )
399
+ Mongous::Document.and( *filters )
400
+ Mongous::Filter#and( *filters )
337
401
  ----
338
402
 
339
403
  * Result:
340
- ** Filter instance.
404
+ ** Mongous::Filter instance.
341
405
 
342
406
  * Parameter:
343
407
  ** filters: 項目名またはフィルタインスタンス
@@ -346,20 +410,34 @@ filter( symbol, filter_or_cond )
346
410
 
347
411
  [source,ruby]
348
412
  ----
349
- コレクション操作クラス #or( *filters )
413
+ Mongous::Document.or( *filters )
414
+ Mongous::Filter#or( *filters )
350
415
  ----
351
416
 
352
417
  * Result:
353
- ** Filter instance.
418
+ ** Mongous::Filter instance.
354
419
 
355
420
  * Parameter:
356
421
  ** filters: 項目名またはフィルタインスタンス
357
422
 
423
+ === ドキュメントを作成.
424
+
425
+ [source,ruby]
426
+ ----
427
+ Mongous::Document.create( **doc )
428
+ ----
429
+
430
+ * Result:
431
+ ** nil.
432
+
433
+ * Parameter:
434
+ ** doc: キーワード引数.
435
+
358
436
  === ドキュメントを保存.
359
437
 
360
438
  [source,ruby]
361
439
  ----
362
- ドキュメント操作オブジェクト #save
440
+ Mongous::Document#save
363
441
  ----
364
442
 
365
443
  * Result:
@@ -369,7 +447,7 @@ filter( symbol, filter_or_cond )
369
447
 
370
448
  [source,ruby]
371
449
  ----
372
- ドキュメント操作オブジェクト #to_hash
450
+ Mongous::Document#to_hash
373
451
  ----
374
452
 
375
453
  * Result:
@@ -379,7 +457,7 @@ filter( symbol, filter_or_cond )
379
457
 
380
458
  [source,ruby]
381
459
  ----
382
- ドキュメント操作オブジェクト #to_hash
460
+ Mongous::Document#to_json
383
461
  ----
384
462
 
385
463
  * Result:
@@ -389,8 +467,8 @@ filter( symbol, filter_or_cond )
389
467
 
390
468
  [source,ruby]
391
469
  ----
392
- ドキュメント操作オブジェクト #[]( field_name )
393
- ドキュメント操作オブジェクト #field_name
470
+ Mongous::Document#[]( field_name )
471
+ Mongous::Document#field_name
394
472
  ----
395
473
 
396
474
  * Result:
@@ -403,8 +481,8 @@ filter( symbol, filter_or_cond )
403
481
 
404
482
  [source,ruby]
405
483
  ----
406
- ドキュメント操作オブジェクト #[]=( field_name, field_value )
407
- ドキュメント操作オブジェクト #field_name = field_value
484
+ Mongous::Document#[]=( field_name, field_value )
485
+ Mongous::Document#field_name = field_value
408
486
  ----
409
487
 
410
488
  * Result: