diff options
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/test/erlang_views.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/share/www/script/test/erlang_views.js b/share/www/script/test/erlang_views.js index 2af26b5a..c3201cdd 100644 --- a/share/www/script/test/erlang_views.js +++ b/share/www/script/test/erlang_views.js @@ -93,5 +93,40 @@ couchTests.erlang_views = function(debug) { var xhr = CouchDB.request("GET", url); T(xhr.status == 200, "standard get should be 200"); T(xhr.responseText == "head2tail"); + + // Larger dataset + + db.deleteDb(); + db.createDb(); + var words = "foo bar abc def baz xxyz".split(/\s+/); + + var docs = []; + for(var i = 0; i < 250; i++) { + var body = []; + for(var j = 0; j < 100; j++) { + body.push({ + word: words[j%words.length], + count: j + }); + } + docs.push({ + "_id": "test-" + i, + "words": body + }); + } + T(db.bulkSave(docs).length, 250, "Saved big doc set."); + + var mfun = 'fun({Doc}) -> ' + + 'Words = proplists:get_value(<<"words">>, Doc), ' + + 'lists:foreach(fun({Word}) -> ' + + 'WordString = proplists:get_value(<<"word">>, Word), ' + + 'Count = proplists:get_value(<<"count">>, Word), ' + + 'Emit(WordString , Count) ' + + 'end, Words) ' + + 'end.'; + + var rfun = 'fun(Keys, Values, RR) -> length(Values) end.'; + var results = db.query(mfun, rfun, null, null, "erlang"); + alert(JSON.stringify(results)); }); }; |