Module to manage access to databases in couchdb.
Object that abstract access to a CouchDB database A Database object could act as a Dict object.
Properties
Methods
Get infos of database
Returns: | dict |
---|
Test if document exist in database
Parameters: |
|
---|---|
Returns: | boolean, True if document exist |
Get document from database
Args: :param docid: str, document id to retrieve default: default result :param rev: if specified, allow you to retrieve a specifiec revision of document
Returns: | dict, representation of CouchDB document as a dict. |
---|
retrieve revisions of a doc
Parameters: |
|
---|
dict with revisions as member, if false return only revisions
Returns: | dict: ‘_rev_infos’ member if you have set with_doc |
---|
to True :
{
"_revs_info": [
{"rev": "123456", "status": "disk"},
{"rev": "234567", "status": "missing"},
{"rev": "345678", "status": "deleted"},
]
}
If False, return current revision of the document, but with an additional field, _revs, the value being a list of the available revision IDs.
Save one documents or multiple documents.
Parameters: |
|
---|---|
Returns: | dict or list of dict: dict or list are updated |
with doc ‘_id’ and ‘_rev’ properties returned by CouchDB server.
delete a document or a list of document
Parameters: |
|
---|
of documents or list with _id and _rev, optionnaly _deleted member set to true. See _bulk_docs document on couchdb wiki.
Returns: | list of doc or dict like: |
---|
{"ok":true,"rev":"2839830636"}
iter documents of a db
Parameters: |
|
---|
Add attachement to a document.
Parameters: |
|
---|
If you don’t set it, it will be autodetected.
Returns: | bool, True if everything was ok. |
---|
Example:
>>> db = self.server.create_db('simplecouchdb_test')
>>> doc = { 'string': 'test', 'number': 4 }
>>> db.save(doc)
>>> text_attachment = "un texte attaché"
>>> db.add_attachment(doc, text_attachment, "test", "text/plain")
True
>>> db.get_attachment(doc, "test")
u'un texte attaché'
>>> db.delete_attachment(doc, 'test')
>>> db.get_attachment(doc, 'test')
None
>>> self.server.delete_db('simplecouchdb_test')
get attachment in document
Parameters: |
|
---|---|
Returns: | str, attachment |
delete attachement of documen
Parameters: |
|
---|---|
Returns: | dict, withm member ok setto True if delete was ok. |
sync all views definition stored in cache.
see Views classes for more info.
Get all documents in a database. It correspond to somedatabase/all_docs call
Returns: | AllDocumentsView instance. |
---|
See Views classes documentation
Returns: | View instance. |
---|
See Views classes documentation
Returns: | TemporaryView instance |
---|
See also
References Server class, Views classes