working on List
This commit is contained in:
19
bolt.go
19
bolt.go
@@ -13,6 +13,25 @@ func NewBolt(path string) (*Bolt, error) {
|
||||
}, err
|
||||
}
|
||||
|
||||
func (b *Bolt) List(ns []string, limits ...string) ([]string, error) {
|
||||
namespace := resolveNamespace(ns)
|
||||
limits = resolveLimits(limits)
|
||||
found := []string{}
|
||||
err := b.db.View(func(tx *bolt.Tx) error {
|
||||
bucket := tx.Bucket([]byte(namespace))
|
||||
if bucket == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
c := bucket.Cursor()
|
||||
for k, _ := c.Seek([]byte(limits[0])); k != nil; k, _ = c.Next() {
|
||||
found = append(found, string(k))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return found, err
|
||||
}
|
||||
|
||||
func (b *Bolt) Get(key string, ns ...string) ([]byte, error) {
|
||||
namespace := resolveNamespace(ns)
|
||||
var result []byte
|
||||
|
||||
Reference in New Issue
Block a user