incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Lenz <cml...@gmx.de>
Subject Re: Newbie: How to create a View
Date Mon, 21 Jul 2008 09:32:44 GMT
On 20.07.2008, at 19:34, Sho Fukamachi wrote:
> as a fellow newbie embarked on a CouchDB crash course I hope I can  
> help.
>
> Can you access Futon, the couchdb web interface? If you can, create  
> a database $MY_DB and switch to it.
>
> Choose a namespace for your view ($VIEW) (ie just make something  
> up!). Then create a new document in that database with the name  
> "_design/$VIEW".
>
> Futon should now switch to your new document. Create a field in it  
> called "views". Save.
>
> Futon is a bit weird about how it presents text editors for fields,  
> so first put "{}" into the views field and save. Then, double click  
> it again and you should have a nice big text window.
>
> Now copy this into the views field:
>
> {
>   "get_all": {
>       "map": "function(doc) { emit(null, doc); }"
>   }
> }
>
> And save.

Actually, it's a bit simpler than that :)

1. If you don't already have a database, create one.
2. Switch the "Custom Query" in the view dropdown at the top right.
3. Type in your query and test/refine it until it does what you want  
it to do.
4. Click the "Save As" button at the bottom right.
5. In the dialog, enter the design doc ID and the name of the view.
6. You're done.

Cheers,
--
Christopher Lenz
   cmlenz at gmx.de
   http://www.cmlenz.net/


Mime
View raw message