diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 52 |
1 files changed, 25 insertions, 27 deletions
@@ -98,56 +98,54 @@ buckets, err := db.Buckets() ``` +### Key/Value Access -### Cursors - -Cursors provide access to a specific bucket within a transaction. - - -#### Creating a read-only cursor +#### Retrieve a value for a specific key ```go t, err := db.Transaction() -c, err := b.Cursor("widgets") +value, err := t.Get("widgets", []byte("foo")) +value, err := t.GetString("widgets", "foo") ``` -#### Creating a read/write cursor +#### Set the value for a key ```go t, err := db.RWTransaction() -c, err := t.RWCursor("widgets") +err := t.Put("widgets", []byte("foo"), []byte("bar")) +err := t.PutString("widgets", "foo", "bar") ``` -#### Iterating over a cursor +#### Delete a given key ```go -for k, v, err := c.First(); k != nil; k, v, err = c.Next() { - if err != nil { - return err - } - ... DO SOMETHING ... -} +t, err := db.RWTransaction() +err := t.Delete("widgets", []byte("foo")) +err := t.DeleteString("widgets", "foo") ``` -#### Retrieve a value for a specific key -```go -value, err := c.Get([]byte("foo")) -value, err := c.GetString("foo") -``` +### Cursors + +Cursors provide fast read-only access to a specific bucket within a transaction. -#### Set the value for a key (RWCursor only) + +#### Creating a read-only cursor ```go -err := c.Put([]byte("foo"), []byte("bar")) -err := c.PutString("foo", "bar") +t, err := db.Transaction() +c, err := b.Cursor("widgets") ``` -#### Delete a given key +#### Iterating over a cursor ```go -err := c.Delete([]byte("foo")) -err := c.DeleteString("foo") +for k, v, err := c.First(); k != nil; k, v, err = c.Next() { + if err != nil { + return err + } + ... DO SOMETHING ... +} ``` |