Re: Pass search term (key) to ViewField

16 views
Skip to first unread message

Alexander Shorin

unread,
Jan 18, 2013, 3:49:41 AM1/18/13
to couchdb...@googlegroups.com
Hi Jason!

There you have two cases:

1. Through Database.view[1] method:

for row in db.view('by_post_id', key=3545639712):
print row

2. Through ViewField (assuming there is such for Post mapping):

for row in Post.by_post_id(db, key=3545639712):
print row

Both are equivalent: ViewField (actually, ViewDefinition) is just a
wrapper around Database.view method. Any query parameters you have to
pass as keyword arguments.

[1] http://packages.python.org/CouchDB/client.html#couchdb.client.Database.view
--
,,,^..^,,,


On Fri, Jan 18, 2013 at 5:44 AM, <jason...@fullboar.ca> wrote:
> Hi,
>
> Now that I have ViewFied working (thanks Kxepal) how do I pass in a key for
> filtering purposes? For example, using curl I can do this:
>
> curl http://host/db/_design/posts/_view/by_post_id?key=3545639712
>
> And just get a single document back with a matching key/searchterm. I
> haven't found a way to do this through couchdb-python.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "CouchDB-Python" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/couchdb-python/-/-pmzElFdNrEJ.
> To post to this group, send email to couchdb...@googlegroups.com.
> To unsubscribe from this group, send email to
> couchdb-pytho...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/couchdb-python?hl=en.
Reply all
Reply to author
Forward
0 new messages