Ok, thanks. It will be _a lot_ of views then. I mean, you might want to select songs based on title, album or genre at the same time as you can order by title, album, genre or insert_date
That would mean that I need 3*4=12 views to accomodate all those different "queries"? Another question I have is what benefit do I get when putting several views in one design document? As I understood, this just causes problems like that all views needs to update, thus locking all the views in the design document. Why is it even possible to put several views in one design document then? I am sure I am missing some important point :) Regards, Daniele 2011/6/10 Clement Hallet <[email protected]>: > 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 > >
