summaryrefslogtreecommitdiff
path: root/system/db/init.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-08-22 02:46:53 -0600
committerGitHub <noreply@github.com>2017-08-22 02:46:53 -0600
commit484f36175c7c4ce80de97401b508ed2abacaeb9e (patch)
tree457e0672a506213fa6f97e4cb80b2a5275c58012 /system/db/init.go
parent4b1fe1e9ac1dffbbebecba4a82f1a735a63de4e7 (diff)
parentea66b2652a5f0ff2da6c148d00fd7bd03f004675 (diff)
Merge pull request #186 from ponzu-cms/ponzu-dev
[core] add method to enable new buckets to be created by other packages and addons, cleanup
Diffstat (limited to 'system/db/init.go')
-rw-r--r--system/db/init.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/system/db/init.go b/system/db/init.go
index 48ae641..31e9f3f 100644
--- a/system/db/init.go
+++ b/system/db/init.go
@@ -13,7 +13,22 @@ import (
"github.com/nilslice/jwt"
)
-var store *bolt.DB
+var (
+ store *bolt.DB
+
+ buckets = []string{
+ "__config", "__users",
+ "__addons", "__uploads",
+ "__contentIndex",
+ }
+
+ bucketsToAdd []string
+)
+
+// Store provides access to the underlying *bolt.DB store
+func Store() *bolt.DB {
+ return store
+}
// Close exports the abillity to close our db file. Should be called with defer
// after call to Init() from the same place.
@@ -51,10 +66,8 @@ func Init() {
}
// init db with other buckets as needed
- buckets := []string{
- "__config", "__users", "__contentIndex",
- "__addons", "__uploads",
- }
+ buckets = append(buckets, bucketsToAdd...)
+
for _, name := range buckets {
_, err := tx.CreateBucketIfNotExists([]byte(name))
if err != nil {
@@ -86,6 +99,11 @@ func Init() {
}
}
+// AddBucket adds a bucket to be created if it doesn't already exist
+func AddBucket(name string) {
+ bucketsToAdd = append(bucketsToAdd, name)
+}
+
// InitSearchIndex initializes Search Index for search to be functional
// This was moved out of db.Init and put to main(), because addon checker was initializing db together with
// search indexing initialisation in time when there were no item.Types defined so search index was always