diff options
Diffstat (limited to 'share')
-rw-r--r-- | share/Makefile.am | 1 | ||||
-rw-r--r-- | share/server/loop.js | 1 | ||||
-rw-r--r-- | share/server/render.js | 20 | ||||
-rw-r--r-- | share/www/script/couch_tests.js | 1 |
4 files changed, 23 insertions, 0 deletions
diff --git a/share/Makefile.am b/share/Makefile.am index 89ca9eb5..0fbf602f 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -137,6 +137,7 @@ nobase_dist_localdata_DATA = \ www/script/test/etags_head.js \ www/script/test/etags_views.js \ www/script/test/show_documents.js \ + www/script/test/update_documents.js \ www/script/test/list_views.js \ www/script/test/compact.js \ www/script/test/purge.js \ diff --git a/share/server/loop.js b/share/server/loop.js index 34354769..ff241eed 100644 --- a/share/server/loop.js +++ b/share/server/loop.js @@ -41,6 +41,7 @@ var dispatch = { "rereduce" : Views.rereduce, "validate" : Validate.validate, "show" : Render.show, + "update" : Render.update, "list" : Render.list, "filter" : Filter.filter }; diff --git a/share/server/render.js b/share/server/render.js index 1a9fc5a5..82ceb3ab 100644 --- a/share/server/render.js +++ b/share/server/render.js @@ -166,11 +166,16 @@ function runProvides(req) { //// //// //// + var Render = { show : function(funSrc, doc, req) { var showFun = compileFunction(funSrc); runShow(showFun, doc, req, funSrc); }, + update : function(funSrc, doc, req) { + var upFun = compileFunction(funSrc); + runUpdate(upFun, doc, req, funSrc); + }, list : function(head, req) { runList(funs[0], head, req, funsrc[0]); } @@ -212,6 +217,21 @@ function runShow(showFun, doc, req, funSrc) { } }; +function runUpdate(renderFun, doc, req, funSrc) { + try { + var result = renderFun.apply(null, [doc, req]); + var doc = result[0]; + var resp = result[1]; + if (resp) { + respond(["up", doc, maybeWrapResponse(resp)]); + } else { + renderError("undefined response from update function"); + } + } catch(e) { + respondError(e, funSrc, true); + } +}; + function resetList() { gotRow = false; lastRow = false; diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 91e95b11..86c65bb7 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -67,6 +67,7 @@ loadTest("replication.js"); loadTest("etags_head.js"); loadTest("etags_views.js"); loadTest("show_documents.js"); +loadTest("update_documents.js"); loadTest("list_views.js"); loadTest("compact.js"); loadTest("purge.js"); |