Created
December 18, 2011 11:14
-
-
Save umpirsky/1493051 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from desktopcouch.records.server import CouchDatabase | |
from desktopcouch.records.record import Record | |
RECORD_TYPE_TEST = 'http://umpirsky.com/record-type/test' | |
db = CouchDatabase('desktopcouchbug', create=True) | |
db.put_record(Record({ | |
'record_type': RECORD_TYPE_TEST, | |
'name': 'test record', | |
'dict': {} | |
})) | |
id = None | |
for record in db.get_records(RECORD_TYPE_TEST, True): | |
print record | |
print record.value['dict'] | |
id = '5h5FK4cMbvgSheFDoY5mPT' | |
record = db.get_record(id) | |
print record | |
print record['dict'] | |
prints: | |
<Row id='5h5FK4cMbvgSheFDoY5mPT', key='http://umpirsky.com/record-type/test', value={'record_type': 'http://umpirsky.com/record-type/test', '_rev': '1-277a05ef6810b40f81927d23a5a5f8cd', '_id': '5h5FK4cMbvgSheFDoY5mPT', 'dict': {}, 'name': 'test record'}> | |
{} | |
<desktopcouch.records.Record object at 0x8fa19ec> | |
<desktopcouch.records.RecordDict object at 0xb741508c> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment