mirror of
https://github.com/etcd-io/bbolt.git
synced 2025-05-31 11:42:30 +00:00
Merge pull request #461 from mark-rushakoff/doc-iterate-buckets
Document iterating over buckets
This commit is contained in:
commit
6e1ca38c6a
13
README.md
13
README.md
@ -344,10 +344,15 @@ Next() Move to the next key.
|
|||||||
Prev() Move to the previous key.
|
Prev() Move to the previous key.
|
||||||
```
|
```
|
||||||
|
|
||||||
When you have iterated to the end of the cursor then `Next()` will return `nil`.
|
Each of those functions has a return signature of `(key []byte, value []byte)`.
|
||||||
You must seek to a position using `First()`, `Last()`, or `Seek()` before
|
When you have iterated to the end of the cursor then `Next()` will return a
|
||||||
calling `Next()` or `Prev()`. If you do not seek to a position then these
|
`nil` key. You must seek to a position using `First()`, `Last()`, or `Seek()`
|
||||||
functions will return `nil`.
|
before calling `Next()` or `Prev()`. If you do not seek to a position then
|
||||||
|
these functions will return a `nil` key.
|
||||||
|
|
||||||
|
During iteration, if the key is non-`nil` but the value is `nil`, that means
|
||||||
|
the key refers to a bucket rather than a value. Use `Bucket.Bucket()` to
|
||||||
|
access the sub-bucket.
|
||||||
|
|
||||||
|
|
||||||
#### Prefix scans
|
#### Prefix scans
|
||||||
|
2
tx.go
2
tx.go
@ -271,7 +271,7 @@ func (tx *Tx) close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy writes the entire database to a writer.
|
// Copy writes the entire database to a writer.
|
||||||
// This function exists for backwards compatibility. Use WriteTo() in
|
// This function exists for backwards compatibility. Use WriteTo() instead.
|
||||||
func (tx *Tx) Copy(w io.Writer) error {
|
func (tx *Tx) Copy(w io.Writer) error {
|
||||||
_, err := tx.WriteTo(w)
|
_, err := tx.WriteTo(w)
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user