~ubuntu-branches/ubuntu/precise/desktopcouch/precise

« back to all changes in this revision

Viewing changes to desktopcouch/records/doc/records.txt

  • Committer: Bazaar Package Importer
  • Author(s): Chad MILLER
  • Date: 2011-01-12 15:08:25 UTC
  • mfrom: (1.5.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110112150825-bzvn23kzufr0qdyb
Tags: 1.0.5-0ubuntu1
* New upstream release, skipping a few buggy releases.
* Split code into binary packages:
  - desktopcouch, configuration files and dependencies, but no code.
  - python-desktopcouch: transitional package
  - python-desktopcouch-application: local DB startup and discovery
  - python-desktopcouch-records: library for DB access anywhere
  - python-desktopcouch-recordtypes: support specific data structures
  - desktopcouch-ubuntuone, replication and pairing with cloud service
* Drop patch that some maverick apps incorrectly needed.
  patches/0-items-should-expose-private-data-for-now.patch
* Update package compatibility-version, 6 -> 7.
* Use newer debhelper and use python-support instead of python-central.
* Depend on contemporary python-couchdb, instead of ancient version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
The Records API
2
2
 
3
 
>>> from desktopcouch.records.server import CouchDatabase
4
 
>>> from desktopcouch.records.record import Record
 
3
>>> from desktopcouch.application.server import DesktopDatabase
 
4
>>> from desktopcouch.records import Record
5
5
 
6
6
Create a database object. Your database needs to exist. If it doesn't, you
7
7
can create it by passing create=True.
8
8
 
9
 
 >> db = CouchDatabase('testing', create=True)
 
9
# for this doctest the db is created and passed in, to make it work
 
10
# with the test couchdb instance, but normally you would have to do:
 
11
# >>> db = DesktopDatabase('testing', create=True)
10
12
 
11
13
Create a Record object. Records have a record type, which should be a
12
14
URL.  The URL should point to a human-readable document which
19
21
 
20
22
>>> r['c'] = ['d','e','f']
21
23
 
22
 
Save the record into the database and update its ID and REV with 
 
24
Save the record into the database and update its ID and REV with
23
25
put_record.  Before you put the record the first time, the ID and REV
24
26
may be unset:
25
27
 
54
56
To create a view:
55
57
 
56
58
>>> map_js = """function(doc) { emit(doc._id, null) }"""
57
 
>>> reduce_js = None
58
 
>>> db.add_view("blueberries", map_js, reduce_js, design_doc)
 
59
>>> db.add_view("blueberries", map_js, design_doc=design_doc)
59
60
 
60
61
List views for a given design document:
61
62