summaryrefslogtreecommitdiff
path: root/system/db/init.go
diff options
context:
space:
mode:
authorSteve <nilslice@gmail.com>2016-10-19 00:09:28 -0700
committerGitHub <noreply@github.com>2016-10-19 00:09:28 -0700
commit0c77f3e89ac26913ce4b7de68fe9f5589ae77d8f (patch)
tree859e76f6d1335133ba8f62da72f068e79331880c /system/db/init.go
parent2f3985491363dc0658ad8cf3a415a77c1825a67a (diff)
parentc74bcc2ec1be59ded3634de1a871c73d9dffba98 (diff)
Merge pull request #3 from bosssauce/ponzu-dev
[fundamental feature] Content type posts are sorted by time and cached in Admin, API coming soon.
Diffstat (limited to 'system/db/init.go')
-rw-r--r--system/db/init.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/system/db/init.go b/system/db/init.go
index 2d73b35..1a5ed25 100644
--- a/system/db/init.go
+++ b/system/db/init.go
@@ -22,12 +22,17 @@ func Init() {
}
err = store.Update(func(tx *bolt.Tx) error {
- // initialize db with all content type buckets
+ // initialize db with all content type buckets & sorted bucket for type
for t := range content.Types {
_, err := tx.CreateBucketIfNotExists([]byte(t))
if err != nil {
return err
}
+
+ _, err = tx.CreateBucketIfNotExists([]byte(t + "_sorted"))
+ if err != nil {
+ return err
+ }
}
// init db with other buckets as needed
@@ -65,6 +70,13 @@ func Init() {
log.Fatal("Coudn't initialize db with buckets.", err)
}
+ // sort all content into type_sorted buckets
+ go func() {
+ for t := range content.Types {
+ SortContent(t)
+ }
+ }()
+
}
// SystemInitComplete checks if there is at least 1 admin user in the db which