[SERVER-3352] Map-Reduce JS increment operators (++, +=1) do not work Created: 30/Jun/11 Updated: 12/Jul/16 Resolved: 12/Oct/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | JavaScript, MapReduce |
| Affects Version/s: | 1.8.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Pete Campbell | Assignee: | Antoine Girbal |
| Resolution: | Done | Votes: | 0 |
| Labels: | query | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
osx snow leopard, ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] |
||
| Operating System: | OS X |
| Participants: |
| Description |
|
In my reduce function, I can only increment a counter with result.counter += value.counter These alternatives do not work: result.counter++ Full code: def total (query = nil) reduce_fn = "function(key, values) { ; ); results_collection = Contact.collection.map_reduce(map_fn, reduce_fn, {:out => {:inline => 1}, :raw => true, :query => query})['results'] end |
| Comments |
| Comment by Azat Khuzhin [ 23/Mar/12 ] |
|
Here it is #5379 |
| Comment by Azat Khuzhin [ 23/Mar/12 ] |
|
I have the same issue, must I create a new ticket, or you reopen this, and I post some usefull information? |
| Comment by Antoine Girbal [ 12/Oct/11 ] |
|
This has been verified to work with mongo 2.0 and master branch. ); }" , "reduce" : "function(key, values) { total = {count: 0}; for (var i = 0; i < values.length; ++i) { total.count++; }; return total; }" , "out" : { "replace" : "mrtest"}} Pete, marking as resolved, if you have further clues on the issue please reopen. |
| Comment by Antoine Girbal [ 05/Jul/11 ] |
|
what do you mean by fails? Note that in any case it is usually not going to be consistent to do "+ constant" in a reduce. |