-
Notifications
You must be signed in to change notification settings - Fork 9
/
core_common.go
40 lines (38 loc) · 1 KB
/
core_common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package nutshttp
import (
"github.com/xujiajun/nutsdb"
)
// GetAllBuckets Regular obtains all buckets
func (c *core) GetAllBuckets(ds string, reg string) (buckets []string, err error) {
if err = c.db.View(
func(tx *nutsdb.Tx) error {
var err error
switch ds {
case "string":
err = tx.IterateBuckets(nutsdb.DataStructureBPTree, reg, func(bucket string) bool {
buckets = append(buckets, bucket)
return true
})
case "list":
err = tx.IterateBuckets(nutsdb.DataStructureList, reg, func(bucket string) bool {
buckets = append(buckets, bucket)
return true
})
case "set":
err = tx.IterateBuckets(nutsdb.DataStructureSet, reg, func(bucket string) bool {
buckets = append(buckets, bucket)
return true
})
case "zset":
err = tx.IterateBuckets(nutsdb.DataStructureSortedSet, reg, func(bucket string) bool {
buckets = append(buckets, bucket)
return true
})
}
return err
},
); err != nil {
return nil, err
}
return buckets, nil
}