Thanks Sean! However, it appears that "show" would format only one document
per request and would not be applied for all documents in the database,
unlike view.

On Tue, May 2, 2017 at 8:58 PM, Sean Lang <[email protected]> wrote:

> This site explains show functions: http://guide.couchdb.org/
> draft/show.html
>
> You would just output it in JSON, rather than HTML like the example shows.
>
> On Tue, May 2, 2017, 15:50 Noel Quintos <[email protected]> wrote:
>
> > Hi!
> >
> > We have a 3rd party client who expect values to be returned (after a GET
> > request) in this format:
> >
> > *[*
> > *        {*
> >                 "attributes": *{*
> >                         "intensity": *-12*,
> >                         "description": "Ground to cloud.",
> >                         "strike_time": "2017/04/17 02:14:32.000",
> >                         "age": *449*,
> >                         "latitude": *46.167*,
> >                         "longitude": *-66.81*
> > *                }*
> > *        }*,
> > *        {*
> >                 "attributes": *{*
> >                         "intensity": *26*,
> >                         "description": "Cloud to ground.",
> >                         "strike_time": "2017/04/17 02:14:30.000",
> >                         "age": *449*,
> >                         "latitude": *46.035*,
> >                         "longitude": *-66.322*
> > *        },*
> > *...*
> > ]
> >   However, the values that you would normally get from CouchDB, even with
> > views, would be something like:
> >
> > {
> > "total_rows":2,
> > "offset":0,
> > rows: [
> >              {
> >                  "id":"223345223355"
> >                  "key":'432523235"
> >                  "value":
> >                            {
> >                                "rev":"1-a34234234"
> >                             }
> >                   "doc":
> >                            {
> >                               "_id":"73234234"
> >                               "_rev":"2-a1324234"
> >                "intensity": *-12*,
> >                "description": "Ground to cloud.",
> >                "strike_time": "2017/04/17 02:14:32.000",
> >                "age": *449*,
> >                "latitude": *46.167*,
> >                "longitude": *-66.81*
> > *                }*
> >                },
> >              {
> >                  "id":"123345223355"
> >                  "key":'132523235"
> >                  "value":
> >                            {
> >                                "rev":"1-234234234"
> >                             }
> >                   "doc":
> >                            {
> >                               "_id":"23234234"
> >                               "_rev":"1-a1324234"
> >                "intensity": *26*,
> >                "description": "Cloud to ground.",
> >                "strike_time": "2017/04/17 02:14:30.000",
> >                "age": *449*,
> >                "latitude": *46.035*,
> >                "longitude": *-66.322*
> > *                }*
> >                },
> > }
> >
> > It does not matter that "attributes" was replaced with "doc" - that is
> > fine. The problem has more to do with the number of levels (it will now
> be
> > 3 levels like xyz["rows"]["doc"]["intensity"] instead of the expected 2
> > levels like xyz["doc"]["intensity"]; and also the reply format (preferred
> > is list of objects but couchDB is giving just one object and the list is
> > just a member.
> >
> > Is there a way to control the format of the returned value? I have seen
> > suggestion to use show function but have not seen enough example for this
> > particular use-case.
> >
> > Thanks!
> >
> >
> > --
> > Noel P. Quintos
> >
>



-- 
Noel P. Quintos

Reply via email to