You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Ron Dyck <pu...@gmail.com> on 2011/10/06 22:11:43 UTC

query parameters in Update Handler functions

I was attempting to use the "in-place" Update Handler function and ran
into an issue with the number of query parameters. After copying the
function from the test suite to ensure I had the proper code, I found
that I was only able to use the first of the query parameters.

The documentation shows the example:
http://127.0.0.1:5984/<my_database>/_design/<my_designdoc>/_update/in-place/<mydocId>?field=title&value=test
In my testing, (after replacing <placeholder> with proper values, I
was unable to read the last param 'value'.

Here's my code:
"in-place": "(function (doc, req) {var field = req.query.field; var
value = req.query.value; var message = 'set ' + field + ' to ' +
value; doc[field] = value; return [doc, message];})",

The value of req.query.field is good.

Your help is appreciated.

ron
--
=================
Ron Dyck
pulpfree1@gmail.com
www.webbtech.net
=================

Re: query parameters in Update Handler functions

Posted by Ron Dyck <pu...@gmail.com>.
Yup single quotes like so ?'foo=bar&baz=faz' works fine.

Thanks for the help!
ron

On Thu, Oct 6, 2011 at 7:20 PM, Robert Newson <rn...@apache.org> wrote:
> & is a shell metacharacter causing curl to run in the background.
> Everything after it is ignored.
>
> try;
>
> curl -vX PUT 'http://localhost:5984/<db-name>/_design/<designdoc>/_update/test-qparams/<docid>?foo=bar&baz=faz'
>
> B.
>
> On 7 October 2011 00:08, Ron Dyck <pu...@gmail.com> wrote:
>> I think it must be how I was using curl, discovered it was not a
>> problem within my php application.
>> Thanks for the help. Am curious what I'm doing wrong with curl though.
>>
>> Here's my curl statement:
>> curl -vX PUT http://localhost:5984/<db-name>/_design/<designdoc>/_update/test-qparams/<docid>?foo=bar&baz=faz
>>
>> On Thu, Oct 6, 2011 at 5:26 PM, Ryan Ramage <ry...@gmail.com> wrote:
>>> Works for me on 1.1  are you on a recent couch?
>>> Maybe this might help you debug:
>>>
>>> function(doc, req) {
>>>        var resp =  {
>>>            headers : {
>>>               'Content-Type' : 'application/json'
>>>            },
>>>             body : JSON.stringify(req.query)
>>>        };
>>>        return [null, resp];
>>> }
>>>
>>> On Thu, Oct 6, 2011 at 2:11 PM, Ron Dyck <pu...@gmail.com> wrote:
>>>> I was attempting to use the "in-place" Update Handler function and ran
>>>> into an issue with the number of query parameters. After copying the
>>>> function from the test suite to ensure I had the proper code, I found
>>>> that I was only able to use the first of the query parameters.
>>>>
>>>> The documentation shows the example:
>>>> http://127.0.0.1:5984/<my_database>/_design/<my_designdoc>/_update/in-place/<mydocId>?field=title&value=test
>>>> In my testing, (after replacing <placeholder> with proper values, I
>>>> was unable to read the last param 'value'.
>>>>
>>>> Here's my code:
>>>> "in-place": "(function (doc, req) {var field = req.query.field; var
>>>> value = req.query.value; var message = 'set ' + field + ' to ' +
>>>> value; doc[field] = value; return [doc, message];})",
>>>>
>>>> The value of req.query.field is good.
>>>>
>>>> Your help is appreciated.
>>>>
>>>> ron
>>>> --
>>>> =================
>>>> Ron Dyck
>>>> pulpfree1@gmail.com
>>>> www.webbtech.net
>>>> =================
>>>>
>>>
>>
>>
>>
>> --
>> =================
>> Ron Dyck
>> pulpfree1@gmail.com
>> www.webbtech.net
>> =================
>>
>



-- 
=================
Ron Dyck
pulpfree1@gmail.com
www.webbtech.net
=================

Re: query parameters in Update Handler functions

Posted by Robert Newson <rn...@apache.org>.
& is a shell metacharacter causing curl to run in the background.
Everything after it is ignored.

try;

curl -vX PUT 'http://localhost:5984/<db-name>/_design/<designdoc>/_update/test-qparams/<docid>?foo=bar&baz=faz'

B.

On 7 October 2011 00:08, Ron Dyck <pu...@gmail.com> wrote:
> I think it must be how I was using curl, discovered it was not a
> problem within my php application.
> Thanks for the help. Am curious what I'm doing wrong with curl though.
>
> Here's my curl statement:
> curl -vX PUT http://localhost:5984/<db-name>/_design/<designdoc>/_update/test-qparams/<docid>?foo=bar&baz=faz
>
> On Thu, Oct 6, 2011 at 5:26 PM, Ryan Ramage <ry...@gmail.com> wrote:
>> Works for me on 1.1  are you on a recent couch?
>> Maybe this might help you debug:
>>
>> function(doc, req) {
>>        var resp =  {
>>            headers : {
>>               'Content-Type' : 'application/json'
>>            },
>>             body : JSON.stringify(req.query)
>>        };
>>        return [null, resp];
>> }
>>
>> On Thu, Oct 6, 2011 at 2:11 PM, Ron Dyck <pu...@gmail.com> wrote:
>>> I was attempting to use the "in-place" Update Handler function and ran
>>> into an issue with the number of query parameters. After copying the
>>> function from the test suite to ensure I had the proper code, I found
>>> that I was only able to use the first of the query parameters.
>>>
>>> The documentation shows the example:
>>> http://127.0.0.1:5984/<my_database>/_design/<my_designdoc>/_update/in-place/<mydocId>?field=title&value=test
>>> In my testing, (after replacing <placeholder> with proper values, I
>>> was unable to read the last param 'value'.
>>>
>>> Here's my code:
>>> "in-place": "(function (doc, req) {var field = req.query.field; var
>>> value = req.query.value; var message = 'set ' + field + ' to ' +
>>> value; doc[field] = value; return [doc, message];})",
>>>
>>> The value of req.query.field is good.
>>>
>>> Your help is appreciated.
>>>
>>> ron
>>> --
>>> =================
>>> Ron Dyck
>>> pulpfree1@gmail.com
>>> www.webbtech.net
>>> =================
>>>
>>
>
>
>
> --
> =================
> Ron Dyck
> pulpfree1@gmail.com
> www.webbtech.net
> =================
>

Re: query parameters in Update Handler functions

Posted by Ron Dyck <pu...@gmail.com>.
I think it must be how I was using curl, discovered it was not a
problem within my php application.
Thanks for the help. Am curious what I'm doing wrong with curl though.

Here's my curl statement:
curl -vX PUT http://localhost:5984/<db-name>/_design/<designdoc>/_update/test-qparams/<docid>?foo=bar&baz=faz

On Thu, Oct 6, 2011 at 5:26 PM, Ryan Ramage <ry...@gmail.com> wrote:
> Works for me on 1.1  are you on a recent couch?
> Maybe this might help you debug:
>
> function(doc, req) {
>        var resp =  {
>            headers : {
>               'Content-Type' : 'application/json'
>            },
>             body : JSON.stringify(req.query)
>        };
>        return [null, resp];
> }
>
> On Thu, Oct 6, 2011 at 2:11 PM, Ron Dyck <pu...@gmail.com> wrote:
>> I was attempting to use the "in-place" Update Handler function and ran
>> into an issue with the number of query parameters. After copying the
>> function from the test suite to ensure I had the proper code, I found
>> that I was only able to use the first of the query parameters.
>>
>> The documentation shows the example:
>> http://127.0.0.1:5984/<my_database>/_design/<my_designdoc>/_update/in-place/<mydocId>?field=title&value=test
>> In my testing, (after replacing <placeholder> with proper values, I
>> was unable to read the last param 'value'.
>>
>> Here's my code:
>> "in-place": "(function (doc, req) {var field = req.query.field; var
>> value = req.query.value; var message = 'set ' + field + ' to ' +
>> value; doc[field] = value; return [doc, message];})",
>>
>> The value of req.query.field is good.
>>
>> Your help is appreciated.
>>
>> ron
>> --
>> =================
>> Ron Dyck
>> pulpfree1@gmail.com
>> www.webbtech.net
>> =================
>>
>



-- 
=================
Ron Dyck
pulpfree1@gmail.com
www.webbtech.net
=================

Re: query parameters in Update Handler functions

Posted by Ryan Ramage <ry...@gmail.com>.
Works for me on 1.1  are you on a recent couch?
Maybe this might help you debug:

function(doc, req) {
	var resp =  {
            headers : {
               'Content-Type' : 'application/json'
            },
             body : JSON.stringify(req.query)
        };
	return [null, resp];
}

On Thu, Oct 6, 2011 at 2:11 PM, Ron Dyck <pu...@gmail.com> wrote:
> I was attempting to use the "in-place" Update Handler function and ran
> into an issue with the number of query parameters. After copying the
> function from the test suite to ensure I had the proper code, I found
> that I was only able to use the first of the query parameters.
>
> The documentation shows the example:
> http://127.0.0.1:5984/<my_database>/_design/<my_designdoc>/_update/in-place/<mydocId>?field=title&value=test
> In my testing, (after replacing <placeholder> with proper values, I
> was unable to read the last param 'value'.
>
> Here's my code:
> "in-place": "(function (doc, req) {var field = req.query.field; var
> value = req.query.value; var message = 'set ' + field + ' to ' +
> value; doc[field] = value; return [doc, message];})",
>
> The value of req.query.field is good.
>
> Your help is appreciated.
>
> ron
> --
> =================
> Ron Dyck
> pulpfree1@gmail.com
> www.webbtech.net
> =================
>