Class ListField
object --+
|
Field --+
|
ListField
Field type for sequences of other fields.
>>> from couchdb import Server
>>> server = Server('http://localhost:5984/')
>>> 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(),
... time = DateTimeField()
... )))
>>> post = Post(title='Foo bar')
>>> post.comments.append(author='myself', content='Bla bla',
... time=datetime.now())
>>> len(post.comments)
1
>>> post.store(db)
<Post ...>
>>> post = Post.load(db, post.id)
>>> comment = post.comments[0]
>>> comment['author']
u'myself'
>>> comment['content']
u'Bla bla'
>>> comment['time']
u'...T...Z'
>>> 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__
|