Search:

Search all manuals
Search this manual
Manual
Couchbase Client Library: Python 1.0
Community Wiki and Resources
Download Client Library
Python Client Library
SDK Forum
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
6 Update Operations
Chapter Sections
Chapters

6.5. Decrement Methods

The decrement methods reduce the value of a given key if the corresponding value can be parsed to an integer value. These operations are provided at a protocol level to eliminate the need to get, update, and reset a simple integer value in the database. All the Python Client Library methods support the use of an explicit offset value that will be used to reduce the stored value in the database.

API Callobject.decr(key [, offset ] [, defaultvalue ] [, expiry ])
Asynchronousno
Description Decrement the value of an existing numeric key. The Couchbase Server stores numbers as unsigned values. Therefore the lowest you can decrement is to zero.
Returnsobject ( Binary object )
Arguments 
key Document ID used to identify the value
offset Integer offset value to increment/decrement (default 1)
defaultvalue Value to be stored if key does not already exist
expiry Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).

The first form of the decr() method accepts the keyname and offset value to be used when reducing the server-side integer. For example, to decrement the server integer dlcounter by 5:

couchbase.decr("dlcounter",5);

The return value is the updated value of the specified key.