diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-16 12:36:37 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-16 12:36:37 -0700 |
commit | 63e8e474d7d26f60eb6f97f92f051a925958819f (patch) | |
tree | 3d52bf8fe4b404cc925a2c2b57e810382252e4fd /db.go | |
parent | Merge branch 'master' of https://github.com/boltdb/bolt (diff) | |
download | dedo-63e8e474d7d26f60eb6f97f92f051a925958819f.tar.gz dedo-63e8e474d7d26f60eb6f97f92f051a925958819f.tar.xz |
Add CreateBucketIfNotExists().
Diffstat (limited to 'db.go')
-rw-r--r-- | db.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -389,6 +389,14 @@ func (db *DB) CreateBucket(name string) error { }) } +// CreateBucketIfNotExists creates a new bucket with the given name if it doesn't already exist. +// This function can return an error if the name is blank, or the bucket name is too long. +func (db *DB) CreateBucketIfNotExists(name string) error { + return db.Do(func(t *RWTransaction) error { + return t.CreateBucketIfNotExists(name) + }) +} + // DeleteBucket removes a bucket from the database. // Returns an error if the bucket does not exist. func (db *DB) DeleteBucket(name string) error { |