Class ListField
object --+
|
Field --+
|
ListField
Field type for sequences of other fields.
>>> from couchdb import Server
>>> server = Server('http://localhost:8888/')
>>> db = server.create('python-tests')
>>> class Post(Document):
... title = TextField()
... content = TextField()
... pubdate = DateTimeField(default=datetime.now)
... comments = ListField(DictField(Schema.build(
... author = TextField(),
... content = TextField()
... )))
>>> post = Post(title='Foo bar')
>>> post.comments.append(author='myself', content='Bla bla')
>>> len(post.comments)
1
>>> doc_id = post.store(db)
>>> post = Post.load(db, doc_id)
>>> comment = post.comments[0]
>>> comment['author']
u'myself'
>>> comment['content']
u'Bla bla'
>>> del server['python-tests']
|
__init__(self,
field,
name=None,
default=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
|
|
Inherited from Field :
__get__ ,
__set__
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
|
Inherited from object :
__class__
|
__init__(self,
field,
name=None,
default=None)
(Constructor)
|
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- Overrides:
Field.__init__
|