mongous 0.1.8 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +286 -48
  3. data/README.ja.adoc +288 -50
  4. data/lib/mongous/base.rb +45 -2
  5. data/lib/mongous/document.rb +75 -32
  6. data/lib/mongous/extention.rb +74 -55
  7. data/lib/mongous/filter.rb +316 -233
  8. data/lib/mongous/version.rb +1 -1
  9. data/mongous.gemspec +1 -1
  10. data/sample/connect_auto_0.rb +9 -0
  11. data/sample/declare_compact_1.rb +7 -9
  12. data/sample/declare_compact_2.rb +38 -0
  13. data/sample/declare_label_1.rb +10 -8
  14. data/sample/declare_ndex_1.rb +9 -7
  15. data/sample/declare_ndex_2.rb +10 -8
  16. data/sample/declare_strict_1.rb +14 -12
  17. data/sample/declare_strict_2.rb +5 -5
  18. data/sample/{multi_docs_1.rb → multi_collection_1.rb} +0 -2
  19. data/sample/multi_collection_2.rb +61 -0
  20. data/sample/multi_collection_3.rb +24 -0
  21. data/sample/query_basic_1.rb +8 -3
  22. data/sample/query_basic_2.rb +11 -6
  23. data/sample/query_basic_3.rb +2 -5
  24. data/sample/query_basic_4.rb +3 -6
  25. data/sample/query_basic_5.rb +2 -5
  26. data/sample/query_basic_6.rb +35 -22
  27. data/sample/query_detail_1.rb +3 -3
  28. data/sample/query_detail_2.rb +3 -3
  29. data/sample/query_detail_3.rb +5 -5
  30. data/sample/query_filter_1.rb +44 -0
  31. data/sample/query_filter_2.rb +48 -0
  32. data/sample/{query_super_1.rb → query_find_1.rb} +6 -6
  33. data/sample/query_select_1.rb +54 -0
  34. data/sample/query_skip_limit_1.rb +48 -0
  35. data/sample/query_skip_limit_2.rb +58 -0
  36. data/sample/query_sort_1.rb +43 -0
  37. data/sample/save_basic_1.rb +2 -7
  38. data/sample/save_basic_2.rb +2 -7
  39. data/sample/save_basic_3.rb +2 -7
  40. data/sample/save_detail_1.rb +7 -6
  41. data/sample/save_detail_2.rb +7 -6
  42. data/sample/save_detail_3.rb +11 -10
  43. data/sample/save_verify_1.rb +7 -6
  44. data/sample/save_verify_2.rb +0 -2
  45. data/sample/save_verify_3.rb +1 -3
  46. data/sample/save_verify_4.rb +0 -2
  47. data/sample/save_verify_5.rb +3 -5
  48. data/sample/save_verify_6.rb +3 -5
  49. data/sample/save_verify_7.rb +21 -0
  50. data/sample/update_basic_1.rb +9 -0
  51. data/sample/zap_basic_1.rb +1 -5
  52. data/sample/zap_basic_2.rb +2 -6
  53. data/sample/zap_basic_3.rb +2 -6
  54. data/sample/zbenchmark_search_1.rb +114 -0
  55. data/sample/zbenchmark_search_2.rb +114 -0
  56. data/sample/zbenchmark_search_3.rb +88 -0
  57. metadata +20 -12
  58. data/sample/multi_docs_2.rb +0 -58
  59. data/sample/query_basic_7.rb +0 -38
  60. data/sample/query_limit_1.rb +0 -44
  61. data/sample/query_order_1.rb +0 -49
  62. data/sample/query_projection_1.rb +0 -44
  63. data/sample/template_article.rb +0 -5
  64. data/sample/template_person.rb +0 -12
@@ -1,58 +0,0 @@
1
-
2
- require "mongous"
3
-
4
- Mongous.connect!
5
-
6
- class Book1
7
- include Mongous::Document
8
- end
9
-
10
- class Book2
11
- include Mongous::Document
12
-
13
- field :title
14
- field :publisher
15
- field :author
16
- field :style
17
- field :price
18
- field :page
19
- field :publish_at
20
- field :isbn
21
- field :lang
22
-
23
- verify :strict
24
- end
25
-
26
- class Book3
27
- include Mongous::Document
28
-
29
- field :title, :must
30
- field :author,
31
- field :publisher,
32
- field :price, Integer, (0..1_000_000)
33
- field :page, Integer, proc{ page > 0 }
34
- field :publish_at, Date, &proc{ Date.today }
35
- field :isbn, proc{ isbn? }
36
- field :lang, &proc{ "ja" }
37
-
38
- verify :strict
39
- verify { having?( title ) }
40
- verify do
41
- having?( author ) | having?( publisher )
42
- end
43
-
44
- def isbn?
45
- isbn&.gsub(/[\D]*/, '').size == 13
46
- end
47
- end
48
-
49
-
50
- pp Book1.fields
51
- puts
52
-
53
- pp Book2.fields
54
- puts
55
-
56
- pp Book3.fields
57
- puts
58
-
@@ -1,38 +0,0 @@
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
-
@@ -1,44 +0,0 @@
1
-
2
- require "mongous"
3
-
4
- Mongous.connect!
5
-
6
- class Item
7
- include Mongous::Document
8
- end
9
-
10
-
11
- (0...10).each do |n|
12
- if item = Item.filter( n: n ).first
13
- item
14
- else
15
- Item.create( n: n )
16
- end
17
- end
18
- puts
19
-
20
- Item.each do |item|
21
- p item
22
- end
23
- puts
24
-
25
- Item.filter.skip(2).each do |item|
26
- p item
27
- end
28
- puts
29
-
30
- Item.filter.limit(3).each do |item|
31
- p item
32
- end
33
- puts
34
-
35
- Item.filter.skip(4).limit(5).each do |item|
36
- p item
37
- end
38
- puts
39
-
40
- Item.filter.offset(4).limit(5).each do |item|
41
- p item
42
- end
43
- puts
44
-
@@ -1,49 +0,0 @@
1
-
2
- require "mongous"
3
-
4
- Mongous.connect!
5
-
6
- class Item
7
- include Mongous::Document
8
- end
9
-
10
-
11
- (0...10).each do |n|
12
- if item = Item.filter( n: n ).first
13
- item
14
- else
15
- Item.create( n: n )
16
- end
17
- end
18
- puts
19
-
20
- Item.each do |item|
21
- p item
22
- end
23
- puts
24
-
25
- Item.filter.sort(n: 1).each do |item|
26
- p item
27
- end
28
- puts
29
-
30
- Item.filter.sort(n: -1).each do |item|
31
- p item
32
- end
33
- puts
34
-
35
- Item.filter.order(n: -1).each do |item|
36
- p item
37
- end
38
- puts
39
-
40
- Item.filter( n: (3...8) ).order(n: -1).each do |item|
41
- p item
42
- end
43
- puts
44
-
45
- Item.filter( n: [0,2,4,6,8] ).order(n: -1).each do |item|
46
- p item
47
- end
48
- puts
49
-
@@ -1,44 +0,0 @@
1
-
2
- require "mongous"
3
-
4
- Mongous.connect!
5
-
6
- class Label
7
- include Mongous::Document
8
- end
9
-
10
-
11
- (0...10).each do |n|
12
- if label = Label.filter( n: n ).first
13
- label
14
- else
15
- Label.create( n: n, tag: [0x40 + n].pack("C") )
16
- end
17
- end
18
- puts
19
-
20
- Label.each do |label|
21
- p label
22
- end
23
- puts
24
-
25
- Label.filter.projection( tag: 1 ).each do |label|
26
- p label
27
- end
28
- puts
29
-
30
- Label.filter.projection( _id: 0, n: 1 ).each do |label|
31
- p label
32
- end
33
- puts
34
-
35
- Label.filter.select( _id: 0, n: 1, tag: 1 ).each do |label|
36
- p label
37
- end
38
- puts
39
-
40
- Label.filter( n: [0,2,4,6,8] ).select( _id: 0, n: 1, tag: 1 ).each do |label|
41
- p label
42
- end
43
- puts
44
-
@@ -1,5 +0,0 @@
1
-
2
- class Article
3
- include Mongous::Document
4
- end
5
-
@@ -1,12 +0,0 @@
1
-
2
- class Person
3
- include Mongous::Document
4
-
5
- field :fullname
6
- field :username
7
- field :age, Integer
8
- field :created_at, Date, &proc{ Date.today }
9
-
10
- verify :strict
11
- end
12
-