Re: Howto edit design documents

2017-08-14 Thread Eiri
Yes, jq is json manipulation tool, so it can’t format javascript function in “map” attribute, it treats it just as a string. The thing with line-breaks is that even while document with multiline formatted function is a valid design document (i.e. the function can be evaluated as javascript)

Re: Howto edit design documents

2017-08-14 Thread Ronny Berndt
@Stefan: Thanks for the hint, couchdb-compile looks nice! @Eric If i search for that, i saw jq as json tool. jq formats the key/value pairs of the json well, but i doesn’t see a possibility to format the line breaks in the functions (e.g. map) itself? So after download \n has to be converted

Re: Howto edit design documents

2017-08-14 Thread Eiri
To the first one any pretty printing command line utility will work, I really like jq (https://stedolan.github.io/jq/) So with my example just piping to jq with no arguments gives formatted json which then could be sent to file: $ curl http://localhost:5984/koi/_design/ddoc -s | jq . {

Re: Howto edit design documents

2017-08-14 Thread Stefan du Fresne
One way of going about this is to use a tool like couchdb-compile (https://github.com/jo/couchdb-compile ). You then edit your ddoc on disk using that format (which is also convenient to commit to source control, diff it nicely etc) and when you want to

Re: Howto edit design documents

2017-08-14 Thread Ronny Berndt
Hi Eric, thank you for your answer. My problem is, if you get the design doc, you get one line of json (no linebreaks, etc…). How to reformat to 1. a doc with linebreaks to easily edit the file 2. reformat two one line (or isn’T it necessary for the upload)? all with command line tools (or

Re: Howto edit design documents

2017-08-14 Thread aa mm
3. I think you can edit the design document on Fauxton to add a list function. As far as I know it's not as easy as adding a map or reduce. בתאריך 14 באוג׳ 2017 05:13 PM,‏ "Eiri" כתב: Hi Ronny, For me “a-ha” moment was to realise that design document is just an ordinary CouchDB

Re: Howto edit design documents

2017-08-14 Thread Eiri
Hi Ronny, For me “a-ha” moment was to realise that design document is just an ordinary CouchDB document, so it can be created and updated with any http client: curl, httpie, whatnot. I’ve writed up a gist with basic demo on using curl for that: