diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-21 15:47:28 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-01-21 15:47:28 -0700 |
commit | 9e26598765d7ac24e91a21b50267312ead664ae3 (patch) | |
tree | 3a0b51b5848356a5dd743e0df43fc80467992b95 | |
parent | Update README.md (diff) | |
download | dedo-9e26598765d7ac24e91a21b50267312ead664ae3.tar.gz dedo-9e26598765d7ac24e91a21b50267312ead664ae3.tar.xz |
Update README.md
-rw-r--r-- | README.md | 40 |
1 files changed, 27 insertions, 13 deletions
@@ -96,31 +96,45 @@ Cursors provide access to a specific bucket within a transaction. ```go t, err := db.Transaction() -b, err := t.Bucket("widgets") -c, err := b.Cursor() +c, err := b.Cursor("widgets") ``` #### Creating a read/write cursor ```go t, err := db.RWTransaction() -b, err := t.Bucket("widgets") -c, err := b.RWCursor() +c, err := t.RWCursor("widgets") ``` +#### Iterating over a cursor +```go +for k, v, err := c.First(); k != nil; k, v, err = c.Next() { + if err != nil { + return err + } + ... DO SOMETHING ... +} +``` + +#### Retrieve a value for a specific key -* Cursor +```go +value, err := c.Get([]byte("foo")) +value, err := c.GetString("foo") +``` +#### Set the value for a key (RWCursor only) +```go +err := c.Put([]byte("foo"), []byte("bar")) +err := c.PutString("foo", "bar") ``` -DB -Bucket -Transaction / RWTransaction -Cursor / RWCursor -page -meta -branchNode -leafNode +#### Delete a given key + +```go +err := c.Delete([]byte("foo")) +err := c.DeleteString("foo") ``` + |