incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sebastien pastor" <sebastien.pas...@gmx.com>
Subject Re: related documents filtering on several key values
Date Wed, 26 Jan 2011 11:41:33 GMT
Sorry for the garbage at the end of the mail (my webmail trying to do something clever with
urls .... )

 Here the end cleaned 

 To retrieve all objects owned by user AAAA with a status "NEW" and speciality set to "12345"
I would then use something like this: ? startkey=["AAAAA",0,"1245"]&endkey=["aaaaa",1,"NEW"]

 The only problem i can see with this, is, if objects for user AAAA are all with a status="old"
for instance, i will still get at least one line which will be the line refering to the doc
type "user"... Do you see a better way of doing this ? I sure could duplicate speciality in
object documents but that doesn t sound like optimization ;) Thanks in advance (and thanks
for reading a rather long email :) ) Seb

----- Original Message -----
From: sebastien pastor
Sent: 01/26/11 11:11 AM
To: user@couchdb.apache.org
Subject: related documents filtering on several key values

 Hi guys, I am trying to solve what i guess is a trivial problem, i came up with a view that
seems to fulfill my needs but, still... not being an view expert, i wouldn t mind hearing
from your advices here it goes : i have 2 types of documents : { "type":"user" "_id":"AAAA"
"speciality":"13245" } { "type":"object" "user_id":"AAAA" "status":" NEW" ... } what i try
to do is get the list of all documents of type "object" with a specific status for a specific
user AND a specific speciality . I came up with this view : def getTripsByMeID_and_Status(doc):
if doc["type"]=="user": yield [doc['_id'],0,doc[' speciality']], doc if doc["type"]=="object"
: yield [doc['user_id'],1,doc['status']], doc To retrieve all objects owned by user AAAA with
a status "NEW" and speciality set to "12345" I would then use something like this: view/myView?startkey=["AAAA
http://localhost:59840/metickets/_design/trips/_view/getTripsByMeID_and_Status?startkey=[%22aaaaa%22,0,%229090-9403249032-49320-4930-92
 40294032%22]&endkey=[%22aaaaa%22,1,%22NEW%22] ",0,"12345"]&endkey=["AAAA http://localhost:59840/metickets/_design/trips/_view/getTripsByMeID_and_Status?startkey=[%22aaaaa%22,0,%229090-9403249032-49320-4930-9240294032%22]&endkey=[%22aaaaa%22,1,%22NEW%22]
",1,"NEW"] http://localhost:59840/metickets/_design/trips/_view/getTripsByMeID_and_Status?startkey=[%22aaaaa%22,0,%229090-9403249032-49320-4930-9240294032%22]&endkey=[%22aaaaa%22,1,%22NEW%22]
The only problem i can see with this, is, if objects for user AAAA are all with a status="old"
for instance, i will still get at least one line which will be the line refering to the doc
type "user"... Do you see a better way of doing this ? Thanks in advance (and thanks for reading
a rather long email :) ) Seb

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message