1

I am trying to use a view and list function combination in couchdb for returning multiple results, as following

  {
    "_id": "_design/noid",
    "_rev": "5-01bdadc2264f0d20fa2875beb9c264c3",
    "language": "javascript",
    "views": {
    "noid": {
        "map": "function (doc) {\n        emit(doc.id,...}"
    }
},
    "lists": {
    "onefield": "function(head, req) {\n  delete doc._id;\n  delete doc._rev;\n  provides('json', function() {\n    return {'json': doc};\n  });\n}"
}
}

when I run this :

http://localhost:5984/dongdocument/_design/noid/_list/onefield/noid?key="12345"

I always got the following 500 Internal Server error, not sure where am I wrong? thank you

{"error":"render_error","reason":"function raised error: (new ReferenceError(\"doc is not defined\", \"lists.onefield\", 2)) \nstacktrace: ([object Object],[object Object])@lists.onefield:2\nrunList(function (head, req) {delete doc._id;delete doc._rev;provides(\"json\", function () {return {json: doc};});},[object Object],[object Array])@../share/couchdb/server/main.js:989\n(function (head, req) {delete doc._id;delete doc._rev;provides(\"json\", function () {return {json: doc};});},[object Object],[object Array])@../share/couchdb/server/main.js:1036\n(\"_design/noid\",[object Array],[object Array])@../share/couchdb/server/main.js:1517\n()@../share/couchdb/server/main.js:1562\n@../share/couchdb/server/main.js:1573\n"}

Ajeet Shah
  • 18,551
  • 8
  • 57
  • 87
Jamesjin
  • 371
  • 2
  • 6
  • 15
  • Your list function has no `doc` variable, it only has `head` and `req` defined. Read [the documentation](http://docs.couchdb.org/en/1.6.1/couchapp/ddocs.html#list-functions) for some examples of list functions. – Dominic Barnes May 27 '16 at 10:54

0 Answers0