incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clement Hallet <clem...@challet.eu>
Subject Re: One view per "query"?
Date Fri, 10 Jun 2011 09:54:23 GMT
I think you're right

> startkey=[null, null, 0, null]&endkey=[null, null, {}, null]

that query would still return results, the ones wich match all the conditions  : 

 - doc.album = null
 - doc.genre = null
 - some range with doc.insert_date, doc.title (not sure what it would really use)

So if you want to order by insert_date, you have to create a view where the key (or the first
element of it) is the insert_date.


-- 
Clément



Le 10 juin 2011 à 11:41, Daniele Testa a écrit :

> Hi all,
> 
> I just want to check with you guys that I understand things correctly.
> 
> Lets say I have a database that stores music songs.
> 
> Each song has a "title", "insert_date", "album", "genre".
> 
> Now, if I want to do these "queries":
> 
> "All songs that belongs to album=X ordered by title"
> "All songs that belongs to genre=X ordered by insert_date descending"
> "All songs that belongs to genre=X ordered by title"
> "All songs ordered by insert_date descending"
> 
> Etc..
> 
> Is it true that I will have to create an unique view for each of these cases?
> 
> I assume I cannot do something like
> 
> emit( [doc.album, doc.genre, doc.insert_date, doc.title], doc);
> 
> And then just choose what index in that array I want to use? It is
> ordered left-to-right, right?
> 
> That would mean that I cannot do something like
> 
> startkey=[null, null, 0, null]&endkey=[null, null, {}, null]
> 
> .. to get all songs ordered by "insert_date"?
> 
> Regards,
> Daniele


Mime
View raw message