From 5da7c1a8ba70f41a8e92cb1efee1f6c6898a2901 Mon Sep 17 00:00:00 2001 From: "Damien F. Katz" Date: Tue, 20 May 2008 19:57:37 +0000 Subject: Fixed design document view definitions to be consistent with temp views. Changed the name of the map(K,V) call in the javascript views to emit(K,V) git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@658405 13f79535-47bb-0310-9956-ffa450edef68 --- share/server/main.js | 4 ++-- share/www/script/couch_tests.js | 40 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'share') diff --git a/share/server/main.js b/share/server/main.js index e7184682..59acb02f 100644 --- a/share/server/main.js +++ b/share/server/main.js @@ -16,7 +16,7 @@ var map_results = []; // holds temporary emitted values during doc map var sandbox = null; -map = function(key, value) { +emit = function(key, value) { map_results.push([key, value]); } @@ -32,7 +32,7 @@ sum = function(values) { try { // if possible, use evalcx (not always available) sandbox = evalcx(''); - sandbox.map = map; + sandbox.emit = emit; sandbox.sum = sum; } catch (e) {} diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 7b35cf87..cb8e8506 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -59,7 +59,7 @@ var tests = { // has a value of 4, and then returns the document's b value. var mapFunction = function(doc){ if(doc.a==4) - map(null, doc.b); + emit(null, doc.b); }; results = db.query(mapFunction); @@ -208,7 +208,7 @@ var tests = { } // query all documents, and return the doc.integer member as a key. - results = db.query(function(doc){ map(doc.integer, null) }); + results = db.query(function(doc){ emit(doc.integer, null) }); T(results.total_rows == numDocsToCreate); @@ -218,7 +218,7 @@ var tests = { } // do the query again, but with descending output - results = db.query(function(doc){ map(doc.integer, null) }, {descending:true}); + results = db.query(function(doc){ emit(doc.integer, null) }, {descending:true}); T(results.total_rows == numDocsToCreate); @@ -238,7 +238,7 @@ var tests = { T(db.bulkSave(docs).ok); var summate = function(N) {return (N+1)*N/2;}; - var map = function (doc) {map(doc.integer, doc.integer)}; + var map = function (doc) {emit(doc.integer, doc.integer)}; var reduce = function (keys, values) { return sum(values); }; var result = db.reduce_query(map, reduce).result; T(result == summate(numDocs)); @@ -277,7 +277,7 @@ var tests = { var generateListOfCitiesAndState = "function(doc) {" + " for (var i = 0; i < doc.cities.length; i++)" + - " map(doc.cities[i] + \", \" + doc._id, null);" + + " emit(doc.cities[i] + \", \" + doc._id, null);" + "}"; var results = db.query(generateListOfCitiesAndState); @@ -348,7 +348,7 @@ var tests = { // query all documents, and return the doc.foo member as a key. results = db.query(function(doc){ - map(null, doc.longtest); + emit(null, doc.longtest); }); }, @@ -376,7 +376,7 @@ var tests = { } // check that views and key collation don't blow up - var rows = db.query(function(doc) { map(null, doc.text) }).rows; + var rows = db.query(function(doc) { emit(null, doc.text) }).rows; for (var i=0; i