Re: How to use a ViewField

104 views
Skip to first unread message
Message has been deleted

Alexander Shorin

unread,
Jan 15, 2013, 7:26:07 PM1/15/13
to couchdb...@googlegroups.com
Hi Jason!

There you'd missed one step to store defined view in CouchDB:

>>> City.by_typeiscity.sync(db)

The sync() method of ViewField (actually, ViewDefinition) stores
defined view within specified design document in CouchDB, so after
that you may execute it normally.

Looks like documentation have missed this process, but it's described
in couchdb.design module docs.
--
,,,^..^,,,


On Sat, Jan 12, 2013 at 1:40 AM, <jason...@fullboar.ca> wrote:
> Hi,
>
> I'm trying to do something similar to an example I found in the
> http://packages.python.org/CouchDB/mapping.html tutorial. They seem to
> create a ViewField and then execute it to get some results. That just does
> not seem to work for me:
>
> class City(Document):
> name = TextField()
> vicinity = TextField()
>
> by_typeiscity = ViewField('cities', '''function(doc) { emit(doc.name, doc);
> }''')
>
> couch = couchdb.Server('http://192.168.1.55:5984/')
> db = self.couch['foo']
>
> cities = Cities.by_typeiscity(db)
>
> print cities
> <ViewResults <PermanentView '_design/cities/_view/by_typeiscity'> {}>
>
> for c in cities:
> # exception couchdb.http.ResourceNotFound: (u'not_found', u'missing')
>
> Thanks in advance.
>
> --
> 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/-/9CaY2hUh7oAJ.
> 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