couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: how do I invoke a view from within couchdb?
Date Thu, 14 Jan 2010 14:40:05 GMT
Hi Matteo,

I'm doing the same in my (work in progress) OAuth-tokens in database
patch:

http://github.com/janl/couchdb/commit/fb692f2cd05b8b77d6f20f0441591803cedd0e5f#L4R265

Cheers
Jan
--

On 12 Jan 2010, at 18:01, Matteo Caprari wrote:

> Mhh.
> 
> There may have been a misunderstanding here:
> 
> all I want to do is to invoke the equivalent of
> curl http://localhost:5984/users/_design/openid/_view/users_by_openids?key=<openid>
> but from inside an authorization handler.
> 
> Multiple openids can be mapped to a single user, so I can't retrieve
> by user id as the default handler does.
> 
> cheers
> 
> On Tue, Jan 12, 2010 at 4:51 PM, Paul Davis <paul.joseph.davis@gmail.com> wrote:
>> Matteo,
>> 
>> While you could technically do this, it's quite a violation of the
>> properties required for map functions. Identical inputs must lead to
>> identical outputs. Otherwise you get all sorts of wonky when the
>> queried view changes and there's no way to figure out when
>> invalidation should happen.
>> 
>> HTH,
>> Paul Davis
>> 
>> On Tue, Jan 12, 2010 at 8:18 AM, Matteo Caprari
>> <matteo.caprari@gmail.com> wrote:
>>> Hi.
>>> 
>>> In an authorization handler I need to query a view (map only) with a single key.
>>> The map function emits (openid, username) and there is no reduce.
>>> 
>>> I thounk I have to complete the snippet below with couch_view:fold but
>>> can't figure out how to generate
>>> a valid fold function, let alone one that filters on a given key.
>>> 
>>> find_user_with_openid(Db, OpenId) ->
>>>        DesignId = <<"_design/_openid">>,
>>>        ViewName = <<"users_by_openids">>
>>>        Stale = nil,
>>>        {ok, View, Group}  = couch_view:get_map_view(Db, DesignId, ViewName, nil),
>>> 
>>> Thanks.
>>> 
>>> --
>>> :Matteo Caprari
>>> matteo.caprari@gmail.com
>>> 
>> 
> 
> 
> 
> -- 
> :Matteo Caprari
> matteo.caprari@gmail.com


Mime
View raw message