开发者

How to Add a List Function to Futon?

开发者 https://www.devze.com 2023-03-27 08:02 出处:网络
I\'m following the instructions here to add a List Function to my CouchDB: http://guide.couchdb.org/draft/transforming.html

I'm following the instructions here to add a List Function to my CouchDB: http://guide.couchdb.org/draft/transforming.html

When I visit the url corresponding to the list function, I get the message:

{"error":"not_found","reason":"missing_named_view"}

Here is the url corresponding to the list function I've constructed:

edtalmadge.iriscouch.com/burritohunter/_design/export/_list/bar/locations

Here is the url given in the documentation:

/db/_design/foo/_list/list-name/view-name

What am I doing wrong?

Here's what I have done so far:

  1. Added views document to Futon:

     {"_id": "_design/locations",
     "_rev": "16-c0702b81430f6b0d428c7a3e201dfc15",
     "language": "javascrip开发者_开发技巧t",
     "views": {
         "locations": {
         "map": "function(doc) { if(doc.type == 'location') {emit(null, { 'name': doc.name, 'address': doc.address, 'geolocation': doc.geolocation, 'phone': doc.phone, 'open_24': doc.open_24, 'beer': doc.beer, 'rating': doc.rating, 'type': doc.type }); }  }"
       }
     }}
    
  2. Added lists document to Futon:

    {"_id": "_design/export",
    "_rev": "2-99c7be486f53d56926a8dc890e182d01",
    "lists": {
        "bar": "function(head, req) { var row; while (row = getRow()) { return 'foo' }                  
         }",
         "zoom": "function() { return 'zoom!' }"
     }}
    


Either add your list function to your locations design document, or modify the URL for accessing your list function to use the fully qualified view name with _list/listName/designDocName/viewName, like:

edtalmadge.iriscouch.com/burritohunter/_design/export/_list/bar/locations/locations

That URL works currently, returning "foo". (If locations/locations looks weird, it's just because your view name is the same as your design doc name.)

If you don't fully qualify the view in the URL by including the design doc, it is assumed that the view belongs to the same design doc that the list function belongs to.

0

精彩评论

暂无评论...
验证码 换一张
取 消