You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Pérès Vincent <vi...@gmail.com> on 2009/06/13 00:14:27 UTC

How to change/extend the show page of a document?

Hello,

I'm a big fan of JS app and think CouchDB could be really helpful and save
me lot of time !
I'm doing some test using CouchDB backend : building documents, creating
views, displaying them by HTTP request etc. but I have some problem to
imagin how to build the following document (maybe you can help me finding
the best solution / feel free to redirect me to documentation !) :
I have different types of documents : page, location, user, news. I
would like to create two views :
- one 'preview' which is going to be a 'light' page with location
- one 'full' with all locations, users, news related to my page
I built some views to fetch group of pages, users, tags with count etc. but
it return a hash of my documents and I only need on : with a given id. Is it
possible to create a view and giving some parameters (id=xxx) or can I
change the 'show' pages (REST Get)? Maybe I'm wrong and I should build my
doc in an other way?

Not so easy to think 'document', I need some help :)

Thanks a lot !
Vincent

Re: How to change/extend the show page of a document?

Posted by Pérès Vincent <vi...@gmail.com>.
Thanks, I understand the aim :)

I also have another question about the relationship between documents. I
will take the example in "EntityRelationship" about groups and users. User
document store an array of groups ids. It's easy to fetch the users who
belongs to a group... but how to display the group details in the user
document?

ex :
http://localhost:5984/markers_development/_design/users/_view/full?key=vincent<http://localhost:5984/markers_development/_design/markers/_view/full?key=paris>

I would like to display my user document and the groups details he belongs
to.
Could you give me an example?

Thanks a lot !

On Sat, Jun 13, 2009 at 7:47 PM, Chris Anderson <jc...@apache.org> wrote:

> 2009/6/12 Pérès Vincent <vi...@gmail.com>:
> > Hello,
> >
> > Thanks for your answer! So for the following URL :
> > http://localhost:5984/markers_development/_design/markers/_view/full
> >
> > I have the following results :
> >
> > {"total_rows":5,"offset":0,"rows":[
> >
> {"id":"6aa77856599e0fd0b3e84e1369c7cdfb","key":"6aa77856599e0fd0b3e84e1369c7cdfb","value":{"name":"lyon"}},
> >
> {"id":"b04d2d2524c8adf5075fbf5e1bae2118","key":"b04d2d2524c8adf5075fbf5e1bae2118","value":{"name":"Strasbourg"}},
> >
> {"id":"d0d2605d5ccbf6e0726d7604279cad70","key":"d0d2605d5ccbf6e0726d7604279cad70","value":{"name":"Paris"}},
> >
> {"id":"df8144f371bc9ef5e49c7499ea7c0dc3","key":"df8144f371bc9ef5e49c7499ea7c0dc3","value":{"name":"Strasbourg"}},
> > {"id":"paris","key":"paris","value":{"name":"Paris"}}
> > ]}
> >
> > But with :
> >
> http://localhost:5984/markers_development/_design/markers/_view/full?key=paris
> >
> > I got the following error :
> >
> http://localhost:5984/markers_development/_design/markers/_view/full?key=paris
> >
> > -------
> >
> > Wow I just resolve the issue by using quote for the key :
> >
> http://localhost:5984/markers_development/_design/markers/_view/full?key=%22paris%22
> >
>
> For future reference the quotes are necessary because the key can be
> any JSON object not just a string, which gives even more flexibility.
>
> Enjoy!
>
> > It's working, thanks to you :)
> >
> > Vincent
> >
> > On Fri, Jun 12, 2009 at 11:23 PM, Dmitry Unkovsky <oil.crayons@gmail.com
> >wrote:
> >
> >> I'm new to couchdb, but as I recall, view can accept number of
> >> parameters, you can see them here -
> >>
> >>
> http://wiki.apache.org/couchdb/HTTP_view_API#head-d288caa8951ff266fb230d364e5c690c4fd7a28a
> >>
> >> Hope that helps.
> >>
> >
>
>
>
> --
> Chris Anderson
> http://jchrisa.net
> http://couch.io
>

Re: How to change/extend the show page of a document?

Posted by Chris Anderson <jc...@apache.org>.
2009/6/12 Pérès Vincent <vi...@gmail.com>:
> Hello,
>
> Thanks for your answer! So for the following URL :
> http://localhost:5984/markers_development/_design/markers/_view/full
>
> I have the following results :
>
> {"total_rows":5,"offset":0,"rows":[
> {"id":"6aa77856599e0fd0b3e84e1369c7cdfb","key":"6aa77856599e0fd0b3e84e1369c7cdfb","value":{"name":"lyon"}},
> {"id":"b04d2d2524c8adf5075fbf5e1bae2118","key":"b04d2d2524c8adf5075fbf5e1bae2118","value":{"name":"Strasbourg"}},
> {"id":"d0d2605d5ccbf6e0726d7604279cad70","key":"d0d2605d5ccbf6e0726d7604279cad70","value":{"name":"Paris"}},
> {"id":"df8144f371bc9ef5e49c7499ea7c0dc3","key":"df8144f371bc9ef5e49c7499ea7c0dc3","value":{"name":"Strasbourg"}},
> {"id":"paris","key":"paris","value":{"name":"Paris"}}
> ]}
>
> But with :
> http://localhost:5984/markers_development/_design/markers/_view/full?key=paris
>
> I got the following error :
> http://localhost:5984/markers_development/_design/markers/_view/full?key=paris
>
> -------
>
> Wow I just resolve the issue by using quote for the key :
> http://localhost:5984/markers_development/_design/markers/_view/full?key=%22paris%22
>

For future reference the quotes are necessary because the key can be
any JSON object not just a string, which gives even more flexibility.

Enjoy!

> It's working, thanks to you :)
>
> Vincent
>
> On Fri, Jun 12, 2009 at 11:23 PM, Dmitry Unkovsky <oi...@gmail.com>wrote:
>
>> I'm new to couchdb, but as I recall, view can accept number of
>> parameters, you can see them here -
>>
>> http://wiki.apache.org/couchdb/HTTP_view_API#head-d288caa8951ff266fb230d364e5c690c4fd7a28a
>>
>> Hope that helps.
>>
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: How to change/extend the show page of a document?

Posted by Pérès Vincent <vi...@gmail.com>.
Hello,

Thanks for your answer! So for the following URL :
http://localhost:5984/markers_development/_design/markers/_view/full

I have the following results :

{"total_rows":5,"offset":0,"rows":[
{"id":"6aa77856599e0fd0b3e84e1369c7cdfb","key":"6aa77856599e0fd0b3e84e1369c7cdfb","value":{"name":"lyon"}},
{"id":"b04d2d2524c8adf5075fbf5e1bae2118","key":"b04d2d2524c8adf5075fbf5e1bae2118","value":{"name":"Strasbourg"}},
{"id":"d0d2605d5ccbf6e0726d7604279cad70","key":"d0d2605d5ccbf6e0726d7604279cad70","value":{"name":"Paris"}},
{"id":"df8144f371bc9ef5e49c7499ea7c0dc3","key":"df8144f371bc9ef5e49c7499ea7c0dc3","value":{"name":"Strasbourg"}},
{"id":"paris","key":"paris","value":{"name":"Paris"}}
]}

But with :
http://localhost:5984/markers_development/_design/markers/_view/full?key=paris

I got the following error :
http://localhost:5984/markers_development/_design/markers/_view/full?key=paris

-------

Wow I just resolve the issue by using quote for the key :
http://localhost:5984/markers_development/_design/markers/_view/full?key=%22paris%22

It's working, thanks to you :)

Vincent

On Fri, Jun 12, 2009 at 11:23 PM, Dmitry Unkovsky <oi...@gmail.com>wrote:

> I'm new to couchdb, but as I recall, view can accept number of
> parameters, you can see them here -
>
> http://wiki.apache.org/couchdb/HTTP_view_API#head-d288caa8951ff266fb230d364e5c690c4fd7a28a
>
> Hope that helps.
>

Re: How to change/extend the show page of a document?

Posted by Dmitry Unkovsky <oi...@gmail.com>.
I'm new to couchdb, but as I recall, view can accept number of
parameters, you can see them here -
http://wiki.apache.org/couchdb/HTTP_view_API#head-d288caa8951ff266fb230d364e5c690c4fd7a28a

Hope that helps.