2024-01-06 14:46:01 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import bolt "go.etcd.io/bbolt"
|
|
|
|
|
2024-01-09 20:49:23 +00:00
|
|
|
func CreateBucket(name string, db *bolt.DB) error {
|
2024-01-06 14:46:01 +00:00
|
|
|
err :=
|
|
|
|
db.Update(func(tx *bolt.Tx) error {
|
2024-01-09 20:49:23 +00:00
|
|
|
_, err := tx.CreateBucketIfNotExists([]byte(name))
|
2024-01-06 14:46:01 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|