You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by John Le Brasseur <jo...@gmail.com> on 2017/07/19 15:30:56 UTC

CouchDB 2.0.0: '{"error":"invalid_design_doc","reason":"`views.reduce` field must have object type"}

Hi
The command below works for CouchDB 1.6.1 but not for 2.0.0.
I saw it mentioned on the Cloudant website but couldn't see an explanation.
Could someone give me the reason or solution please:

curl -X PUT http://user:pwd@127.0.0.1:5984/database/_design/abc
-d'{"views":{"test":{"map":"function(doc){\n
emit(doc.key,doc.value);\n}"},"reduce":"function(key,values){\n return
count(values)\n;}"}, "language": "javascript"}' -H
"Content-Type:application/json"

reply:
{"error":"invalid_design_doc","reason":"`views.reduce` field must have
object type"}

Many thanks.

John.

Re: CouchDB 2.0.0: '{"error":"invalid_design_doc","reason":"`views.reduce` field must have object type"}

Posted by John Le Brasseur <jo...@gmail.com>.
Thanks Scott.
I thought it was something else completely.
Interestingly CouchDB v 2.0.0 rejected the curl command immediately but v
1.6.1 did not complain.
However, upon opening Futon(1.6.1), the view was completely unusable, as
one would expect.
Credit to those who upgraded CouchDB to 2.0.0

On 19 July 2017 at 17:51, Scott Shattuck <sc...@gmail.com> wrote:

> It looks to me like there's an extra '}' after the map function string and
> before the reduce function string value. This would seem to be consistent
> with the "views.reduce" message which implies the reduce isn't part of the
> test: {} object but instead is one level too high.
>
>
> ss
>
>
> On Wed, Jul 19, 2017 at 9:30 AM, John Le Brasseur <
> johnlebrasseur@gmail.com>
> wrote:
>
> > Hi
> > The command below works for CouchDB 1.6.1 but not for 2.0.0.
> > I saw it mentioned on the Cloudant website but couldn't see an
> explanation.
> > Could someone give me the reason or solution please:
> >
> > curl -X PUT http://user:pwd@127.0.0.1:5984/database/_design/abc
> > -d'{"views":{"test":{"map":"function(doc){\n
> > emit(doc.key,doc.value);\n}"},"reduce":"function(key,values){\n return
> > count(values)\n;}"}, "language": "javascript"}' -H
> > "Content-Type:application/json"
> >
> > reply:
> > {"error":"invalid_design_doc","reason":"`views.reduce` field must have
> > object type"}
> >
> > Many thanks.
> >
> > John.
> >
>

Thanks again.

John

Re: CouchDB 2.0.0: '{"error":"invalid_design_doc","reason":"`views.reduce` field must have object type"}

Posted by Scott Shattuck <sc...@gmail.com>.
It looks to me like there's an extra '}' after the map function string and
before the reduce function string value. This would seem to be consistent
with the "views.reduce" message which implies the reduce isn't part of the
test: {} object but instead is one level too high.


ss


On Wed, Jul 19, 2017 at 9:30 AM, John Le Brasseur <jo...@gmail.com>
wrote:

> Hi
> The command below works for CouchDB 1.6.1 but not for 2.0.0.
> I saw it mentioned on the Cloudant website but couldn't see an explanation.
> Could someone give me the reason or solution please:
>
> curl -X PUT http://user:pwd@127.0.0.1:5984/database/_design/abc
> -d'{"views":{"test":{"map":"function(doc){\n
> emit(doc.key,doc.value);\n}"},"reduce":"function(key,values){\n return
> count(values)\n;}"}, "language": "javascript"}' -H
> "Content-Type:application/json"
>
> reply:
> {"error":"invalid_design_doc","reason":"`views.reduce` field must have
> object type"}
>
> Many thanks.
>
> John.
>