SDK documentation

Hi,

http://pythonhosted.com/couchbase seems to be a broken link. I see the documentation on docs.couchbase.com but was hoping to find something more detailed.

For.e.g the docs don’t talk about document ID’s - i’m trying to create a doc ID using an atomic increment operator but cant seem to figure out how.

cb.counter(‘some_document’, delta=1, initial=10) --> this creates a new document with ID ‘some_document’, though i want to use the value of the counter as the document ID.

Help :slight_smile: – i might be completely off; need more detailed docs!!

Thanks

Sorry! There’s a broken link in the docs. It’s actually pythonhosted.org, not.com! As for your counter ops:

http://pythonhosted.org/couchbase/api/couchbase.html#couchbase.bucket.Bucket.counter shows you everything you should need.

I’ve fixed the broken links in the new docs - they should be available shortly (check tomorrow). Until then you can simply use the pythonhosted.org/couchbase URL

As far as using the counter value as a document ID:

>>> from couchbase.bucket import Bucket
>>> cb = Bucket('couchbase://192.168.72.101/default')
>>> docid = cb.counter('counter_key', delta=1, initial=10).value
>>> docid
>>> cb.upsert(str(docid), "something")
OperationResult<RC=0x0, Key=u'10', CAS=0xf8b0d7f8ed88d313>
>>> cb.get(str(docid))
ValueResult<RC=0x0, Key=u'10', Value=u'something', CAS=0xf8b0d7f8ed88d313, Flags=0x2000000>

However the key itself must be a string, not a number, so you can’t just go cb.upsert(docid, {"something":"here"}), since that would throw an exception. You’d need to wrap it in a str(docid).

Thanks a mega ton Mark! I have just started with CB and am impressed by the work you guys are doing!