mirror of https://github.com/etcd-io/bbolt.git
Update README.md
parent
9e26598765
commit
fe89434c0d
74
README.md
74
README.md
|
@ -1,4 +1,4 @@
|
||||||
bolt
|
Bolt
|
||||||
====
|
====
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
@ -23,36 +23,6 @@ err := db.Close()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Buckets
|
|
||||||
|
|
||||||
Buckets are where your actual key/value data gets stored.
|
|
||||||
You can create new buckets from the database and look them up by name.
|
|
||||||
|
|
||||||
#### Creating a bucket
|
|
||||||
|
|
||||||
```go
|
|
||||||
b, err := db.CreateBucket("widgets")
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Retrieve an existing bucket
|
|
||||||
|
|
||||||
```go
|
|
||||||
b, err := db.Bucket("widgets")
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Retrieve a list of all buckets
|
|
||||||
|
|
||||||
```go
|
|
||||||
buckets, err := db.Buckets()
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Deleting a bucket
|
|
||||||
|
|
||||||
```go
|
|
||||||
err := db.DeleteBucket("widgets")
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Transactions
|
### Transactions
|
||||||
|
|
||||||
Versioning of data in the bucket data happens through a Transaction.
|
Versioning of data in the bucket data happens through a Transaction.
|
||||||
|
@ -87,6 +57,48 @@ err := t.Abort()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Buckets
|
||||||
|
|
||||||
|
Buckets are where your actual key/value data gets stored.
|
||||||
|
You can create new buckets from the database and look them up by name.
|
||||||
|
|
||||||
|
#### Creating a bucket
|
||||||
|
|
||||||
|
```go
|
||||||
|
t, err := db.RWTransaction()
|
||||||
|
err := t.CreateBucket("widgets")
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Renaming a bucket
|
||||||
|
|
||||||
|
```go
|
||||||
|
t, err := db.RWTransaction()
|
||||||
|
err := t.RenameBucket("widgets", "woojits")
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Deleting a bucket
|
||||||
|
|
||||||
|
```go
|
||||||
|
t, err := db.RWTransaction()
|
||||||
|
err := t.DeleteBucket("widgets")
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Retrieve an existing bucket
|
||||||
|
|
||||||
|
```go
|
||||||
|
t, err := db.Transaction()
|
||||||
|
b, err := t.Bucket("widgets")
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Retrieve a list of all buckets
|
||||||
|
|
||||||
|
```go
|
||||||
|
t, err := db.Transaction()
|
||||||
|
buckets, err := db.Buckets()
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Cursors
|
### Cursors
|
||||||
|
|
||||||
Cursors provide access to a specific bucket within a transaction.
|
Cursors provide access to a specific bucket within a transaction.
|
||||||
|
|
Loading…
Reference in New Issue