couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lowry, Matthew" <>
Subject RE: Can I get just the keys from a view? [SEC=UNCLASSIFIED]
Date Thu, 17 Jun 2010 00:42:13 GMT
Yes - I believe a list function is exactly what is needed.
I wasn't aware of this feature. It gets very little mention in the wiki;
all I could find was this page:

which doesn't seem to be linked into the rest of the wiki pages - I only
found it by searching for "_list".

Anyhoo, if I understand the documentation correctly one could have a
list function along the lines of

function(head, req) {
  var row;
  while(row = getRow()) {

and then apply that on any view to, as you say, crop the values and
leave the keys.

Thanks for the advice folks.

-----Original Message-----
From: afters [] 
Sent: Tuesday, 15 June 2010 5:06 PM
Subject: Re: Can I get just the keys from a view? [SEC=UNCLASSIFIED]

I'm fairly new to couch myself, but here goes:

You could use a list function that would crop the values and leave the

Also, you could write a reduce function that does the same - just query
the view with 'group=true' so each view-doc gets its own reduce.


On 15 June 2010 05:26, Lowry, Matthew

> Hi folks. A Couch newbie here with a question regarding the view API.
> Is there any way that I can query a view and get just the key for each

> row, and omit the value?
> The reason I ask is I'm working with a view that generates a massive 
> amount of data - each document in the database generates many hundreds

> of rows in the view. Each row has a large value object. But all I want

> to do is get the keys. So it's wasting a massive amount of time and 
> resources, both client and server side, to have to pull both the key 
> and value object for every row in the view when all I want to see is 
> the key.
> So is there actually a mechanism in the view API to pull just the key 
> from each row of a view? And if not, why not? That would be curiously 
> asymmetrical with the document API, which allows me to get the IDs of 
> all the documents without requesting the documents themselves.
> Cheers.
> IMPORTANT: This email remains the property of the Department of 
> Defence and is subject to the jurisdiction of section 70 of the Crimes

> Act 1914. If you have received this email in error, you are requested 
> to contact the sender and delete the email.

View raw message