diff options
author | John Christopher Anderson <jchris@apache.org> | 2009-02-01 22:21:09 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2009-02-01 22:21:09 +0000 |
commit | cdfe55c54de515581121f6923e8301e8cbea5bcc (patch) | |
tree | 13db216a91aa8ad0f39d30324afa41023334b685 /share/www/script | |
parent | 614f3c26d98ab656e095b5672511d710732f034a (diff) |
Added options member to design docs. Currently the only option is include_designs (views can now run over design docs as well if they need to), the default is false, which is the current behavior. Thanks davisp for the original patch. Closes COUCHDB-156
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@739866 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r-- | share/www/script/couch.js | 4 | ||||
-rw-r--r-- | share/www/script/couch_tests.js | 52 |
2 files changed, 56 insertions, 0 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js index 0a2698ab..96612faa 100644 --- a/share/www/script/couch.js +++ b/share/www/script/couch.js @@ -129,6 +129,10 @@ function CouchDB(name, httpHeaders) { reduceFun = reduceFun.toSource ? reduceFun.toSource() : "(" + reduceFun.toString() + ")"; body.reduce = reduceFun; } + if (options && options.options != undefined) { + body.options = options.options; + delete options.options; + } this.last_req = this.request("POST", this.uri + "_temp_view" + encodeOptions(options), { headers: {"Content-Type": "application/json"}, body: JSON.stringify(body) diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 28a1b9f4..8bdebec1 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -773,6 +773,58 @@ var tests = { } }, + design_options: function(debug) { + var db = new CouchDB("test_suite_db"); + db.deleteDb(); + db.createDb(); + if (debug) debugger; + + //// test the includes_design option + var map = "function (doc) {emit(null, doc._id);}"; + + // we need a design doc even to test temp views with it + var designDoc = { + _id:"_design/fu", + language: "javascript", + options: { + include_design: true + }, + views: { + data: {"map": map} + } + }; + T(db.save(designDoc).ok); + + // should work for temp views + var rows = db.query(map, null, {options:{include_design: true}}).rows; + T(rows.length == 1); + T(rows[0].value == "_design/fu"); + + rows = db.query(map).rows; + T(rows.length == 0); + + // when true, should include design docs in views + rows = db.view("fu/data").rows; + T(rows.length == 1); + T(rows[0].value == "_design/fu"); + + // when false, should not + designDoc.options.include_design = false; + delete designDoc._rev; + designDoc._id = "_design/bingo"; + T(db.save(designDoc).ok); + rows = db.view("bingo/data").rows; + T(rows.length == 0); + + // should default to false + delete designDoc.options; + delete designDoc._rev; + designDoc._id = "_design/bango"; + T(db.save(designDoc).ok); + rows = db.view("bango/data").rows; + T(rows.length == 0); + }, + multiple_rows: function(debug) { var db = new CouchDB("test_suite_db"); db.deleteDb(); |