mongoid-mapreduce 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/mongoid/mapreduce/formula/array_values.rb +2 -2
- data/lib/mongoid/mapreduce/version.rb +1 -1
- metadata +13 -13
data/README.md
CHANGED
@@ -38,7 +38,7 @@ class Employee
|
|
38
38
|
end
|
39
39
|
```
|
40
40
|
|
41
|
-
You can now use the *map_reduce* method on your model to aggregate data
|
41
|
+
You can now use the *map_reduce* method on your model to aggregate data using your choice of aggregation formula.
|
42
42
|
|
43
43
|
```ruby
|
44
44
|
# Create a few example employees
|
@@ -47,7 +47,7 @@ Employee.create :name => 'Bob', :division => 'Software', :age => 25, :awards =>
|
|
47
47
|
Employee.create :name => 'Chris', :division => 'Hardware', :age => 30, :awards => 3, :male => 1, :rooms => [4,5,6]
|
48
48
|
Employee.create :name => 'Darcy', :division => 'Sales', :age => 35, :awards => 3, :male => 0, :rooms => [1,2,3,4,5,6]
|
49
49
|
|
50
|
-
# Aggregate formula: produces 3 records, one for each division.
|
50
|
+
# Aggregate formula (the default): produces 3 records, one for each division.
|
51
51
|
divs = Employee.map_reduce(:division, :fields => [:age, :awards])
|
52
52
|
divs.length # => 3
|
53
53
|
divs.find('Software').age # => 45
|
@@ -58,7 +58,7 @@ divs.keys # => ['Hardware', 'Software', 'Sales']
|
|
58
58
|
divs.has_key?('Sales') # => true
|
59
59
|
divs.to_hash # => { "Software" => ..., "Hardware" => ..., "Sales" => ... }
|
60
60
|
|
61
|
-
# Array Value formula: produces 6 records, one for each room.
|
61
|
+
# Array Value formula: produces 6 records, one for each room. Does not take any fields.
|
62
62
|
rooms = Employee.map_reduce(:rooms, :formula => :array_values)
|
63
63
|
rooms.length # => 6
|
64
64
|
rooms.find(1)._count # => 3
|
@@ -12,8 +12,8 @@ module Mongoid
|
|
12
12
|
options[:count_type] ||= Integer
|
13
13
|
options[:count_field] ||= :_count
|
14
14
|
|
15
|
-
if fields.
|
16
|
-
raise "Error: The Array Values formula
|
15
|
+
if fields.any?
|
16
|
+
raise "Error: The Array Values formula does not take any fields. Please see documentation."
|
17
17
|
end
|
18
18
|
|
19
19
|
@field_name = options[:map_key]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-mapreduce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-09-24 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
16
|
-
requirement: &
|
16
|
+
requirement: &70155909706240 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70155909706240
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bson_ext
|
27
|
-
requirement: &
|
27
|
+
requirement: &70155909705640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.3'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70155909705640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: growl
|
38
|
-
requirement: &
|
38
|
+
requirement: &70155909705180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70155909705180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &70155909704560 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.9.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70155909704560
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70155909703960 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '2.6'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70155909703960
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70155909703380 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: 0.4.3
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70155909703380
|
80
80
|
description: Mongoid MapReduce provides simple aggregation features for your Mongoid
|
81
81
|
models
|
82
82
|
email:
|