1 |
|
2 | (function() {
|
3 | var group_as_stream, most, view_stream;
|
4 |
|
5 | group_as_stream = function(db_uri, app, view, level, min, max) {
|
6 | var params;
|
7 | params = {
|
8 | sorted: false,
|
9 | inclusive_end: true
|
10 | };
|
11 | level = parseInt(level);
|
12 | if (isNaN(level) || level < 0) {
|
13 | return most.empty();
|
14 | }
|
15 | params.group_level = level;
|
16 |
|
17 |
|
18 | if (min != null) {
|
19 | params.startkey = JSON.stringify(min);
|
20 | }
|
21 | if (max != null) {
|
22 | params.endkey = JSON.stringify(max);
|
23 | }
|
24 | return view_stream(db_uri, app, view, params);
|
25 | };
|
26 |
|
27 | module.exports = group_as_stream;
|
28 |
|
29 | view_stream = require('most-couchdb/view-stream');
|
30 |
|
31 | most = require('most');
|
32 |
|
33 | }).call(this);
|