ctrl-alt-delor
ctrl-alt-delor

Reputation: 7745

Get couchdb views to process design-docs as well as other docs

I am trying to get a view in couchdb to include design docs. I have done it in the past, but can not get it to work today.

In a past couchapp there is a file called options.json that contains the text:

{
  "include_design": "true"
}

This results in the design doc containing

"options": {
   "include_design": "true"
},

I added this to the new project, but still the design doc is not processed by my views. Is there something that I missed?


CouchDB 1.7.1

Upvotes: 0

Views: 159

Answers (2)

Femi Oni
Femi Oni

Reputation: 824

@user3405291 is correct the problem is with the string "true" instead of boolean true. CouchDB doesn't save this. Your view is run on the server as a javascript script so you should write it like you write javascript anywhere.

Upvotes: 0

Megidd
Megidd

Reputation: 7962

According to this documentation, include_design option is a boolean.


I double-checked CouchDB to see how it saves Boolean values by adding a document to a sample database with a Boolean value for one of the keys:

$ cat doc--0000 
{"time":"2011", "address":"CT", "include":true}
$ curl -k -X PUT https://admin:**@192.168.1.106:6984/sample/doc--0000 -d @doc--0000 
{"ok":true,"id":"doc--0000","rev":"1-e269c17275e2d21ba9100cd65b304d70"}
$ curl -k -X GET https://admin:**@192.168.1.106:6984/sample/doc--0000 
{"_id":"doc--0000","_rev":"1-e269c17275e2d21ba9100cd65b304d70","time":"2011","address":"CT","include":true}

The double-check confirms that the Boolean values are saved as true NOT "true". I'm not sure, maybe that's the cause of the issue.

Upvotes: 2

Related Questions