diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-15 10:23:00 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-15 10:23:00 -0700 |
commit | e68bc0b4530475503afb34956dfb915673af919c (patch) | |
tree | c1747819b8499d03e4a5348b1f42d1c22b73e3f2 /rwtransaction.go | |
parent | Merge pull request #30 from benbjohnson/examples (diff) | |
download | dedo-e68bc0b4530475503afb34956dfb915673af919c.tar.gz dedo-e68bc0b4530475503afb34956dfb915673af919c.tar.xz |
Add bucket sequence.
Diffstat (limited to 'rwtransaction.go')
-rw-r--r-- | rwtransaction.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/rwtransaction.go b/rwtransaction.go index 92d05a8..568960a 100644 --- a/rwtransaction.go +++ b/rwtransaction.go @@ -66,6 +66,20 @@ func (t *RWTransaction) DeleteBucket(name string) error { return nil } +// NextSequence returns an autoincrementing integer for the bucket. +func (t *RWTransaction) NextSequence(name string) (int, error) { + // Check if bucket already exists. + b := t.Bucket(name) + if b == nil { + return 0, BucketNotFoundError + } + + // Increment and return the sequence. + b.bucket.sequence++ + + return int(b.bucket.sequence), nil +} + // Put sets the value for a key inside of the named bucket. // If the key exist then its previous value will be overwritten. // Returns an error if the bucket is not found, if the key is blank, if the key is too large, or if the value is too large. |