Re: sort by key

2009-09-23 Thread Elf
2009/9/23 Jan Lehnardt : > > On 22 Sep 2009, at 18:39, Elf wrote: > >> 2009/9/22 Ning Tan : >>> >>> On Tue, Sep 22, 2009 at 11:43 AM, Elf wrote: Do not use emit(something, doc), prefer to use include_docs=true (so, emit(something, something_less_than_large_document) when requesting

Re: sort by key

2009-09-22 Thread Jan Lehnardt
On 22 Sep 2009, at 18:39, Elf wrote: 2009/9/22 Ning Tan : On Tue, Sep 22, 2009 at 11:43 AM, Elf wrote: Do not use emit(something, doc), prefer to use include_docs=true (so, emit(something, something_less_than_large_document) when requesting a view. Can you elaborate on this? What if I

Re: sort by key

2009-09-22 Thread Elf
2009/9/22 Ning Tan : > On Tue, Sep 22, 2009 at 11:43 AM, Elf wrote: >> Do not use emit(something, doc), prefer to use include_docs=true (so, >> emit(something, something_less_than_large_document) when requesting a >> view. > > Can you elaborate on this? What if I have a mostly read database (i.e.

Re: sort by key

2009-09-22 Thread Damien Katz
Use a compound key. The first to sort by name, the second by date. Then get all the docs in the range of the first key. function(doc){ if (doc.user && doc.user.name) { emit([doc.user.name, doc.created_time], doc); } } then GET /db/_design/users/_view/by_name?start_key=["user name

Re: sort by key

2009-09-22 Thread Ning Tan
On Tue, Sep 22, 2009 at 11:43 AM, Elf wrote: > Do not use emit(something, doc), prefer to use include_docs=true (so, > emit(something, something_less_than_large_document) when requesting a > view. Can you elaborate on this? What if I have a mostly read database (i.e. I don't care too much about v

Re: sort by key

2009-09-22 Thread Nils Breunese
Dmitriy Novotochinov wrote: Hello everybody! Please help me to implement sorting by key. Here is view function: function(doc){ if (doc.user && doc.user.name) { emit(doc.user.name, doc); } } Query all docs where user.name = user_name: /_design/users/_view/by_name?key=user_n

Re: sort by key

2009-09-22 Thread Elf
Do not use emit(something, doc), prefer to use include_docs=true (so, emit(something, something_less_than_large_document) when requesting a view. 2009/9/22 Dmitriy Novotochinov : > Hello everybody! > > Please help me to implement sorting by key. > > Here is view function: > > function(doc){ >    

Re: sort by key

2009-09-22 Thread Jan-Felix Wittmann
Am 22.09.2009 um 17:32 schrieb Jan-Felix Wittmann: sorry not -> function(doc){ emit(created_at, doc); } this here is better :) function(doc){ emit(doc.created_at, doc); } --Felix

Re: sort by key

2009-09-22 Thread Jan-Felix Wittmann
Hi Dmitriy, Am 22.09.2009 um 14:59 schrieb Dmitriy Novotochinov: Please help me to implement sorting by key. Here is view function: function(doc){ if (doc.user && doc.user.name) { emit(doc.user.name, doc); } } Query all docs where user.name = user_name: /_design/users/_view/by_n

sort by key

2009-09-22 Thread Dmitriy Novotochinov
Hello everybody! Please help me to implement sorting by key. Here is view function: function(doc){ if (doc.user && doc.user.name) { emit(doc.user.name, doc); } } Query all docs where user.name = user_name: /_design/users/_view/by_name?key=user_name Query returns docs sorted by