diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-08 17:01:49 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-08 17:04:02 -0700 |
commit | 57376f090503d7ef5bc38f138e58e64bdea284a3 (patch) | |
tree | e215bb0cf8df72a53b662ff222c24a973e7faac3 /example_test.go | |
parent | Add benchmarks. (diff) | |
download | dedo-57376f090503d7ef5bc38f138e58e64bdea284a3.tar.gz dedo-57376f090503d7ef5bc38f138e58e64bdea284a3.tar.xz |
Rename Transaction to Tx.
I changed the Transaction/RWTransaction types to Tx/RWTx, respectively. This makes the naming
more consistent with other packages such as database/sql. The txnid is changed to txid as well.
Diffstat (limited to 'example_test.go')
-rw-r--r-- | example_test.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/example_test.go b/example_test.go index b4fac38..82db552 100644 --- a/example_test.go +++ b/example_test.go @@ -67,7 +67,7 @@ func ExampleDB_Do() { defer db.Close() // Execute several commands within a write transaction. - err := db.Do(func(t *RWTransaction) error { + err := db.Do(func(t *RWTx) error { if err := t.CreateBucket("widgets"); err != nil { return err } @@ -100,7 +100,7 @@ func ExampleDB_With() { db.Put("people", []byte("susy"), []byte("que")) // Access data from within a read-only transactional block. - db.With(func(t *Transaction) error { + db.With(func(t *Tx) error { v := t.Bucket("people").Get([]byte("john")) fmt.Printf("John's last name is %s.\n", string(v)) return nil @@ -134,17 +134,17 @@ func ExampleDB_ForEach() { // A liger is awesome. } -func ExampleRWTransaction() { +func ExampleRWTx() { // Open the database. var db DB - db.Open("/tmp/bolt/rwtransaction.db", 0666) + db.Open("/tmp/bolt/rwtx.db", 0666) defer db.Close() // Create a bucket. db.CreateBucket("widgets") // Create several keys in a transaction. - rwtxn, _ := db.RWTransaction() + rwtxn, _ := db.RWTx() b := rwtxn.Bucket("widgets") b.Put([]byte("john"), []byte("blue")) b.Put([]byte("abby"), []byte("red")) @@ -152,7 +152,7 @@ func ExampleRWTransaction() { rwtxn.Commit() // Iterate over the values in sorted key order. - txn, _ := db.Transaction() + txn, _ := db.Tx() c := txn.Bucket("widgets").Cursor() for k, v := c.First(); k != nil; k, v = c.Next() { fmt.Printf("%s likes %s\n", string(k), string(v)) @@ -165,10 +165,10 @@ func ExampleRWTransaction() { // zephyr likes purple } -func ExampleRWTransaction_rollback() { +func ExampleRWTx_rollback() { // Open the database. var db DB - db.Open("/tmp/bolt/rwtransaction_rollback.db", 0666) + db.Open("/tmp/bolt/rwtx_rollback.db", 0666) defer db.Close() // Create a bucket. @@ -178,7 +178,7 @@ func ExampleRWTransaction_rollback() { db.Put("widgets", []byte("foo"), []byte("bar")) // Update the key but rollback the transaction so it never saves. - rwtxn, _ := db.RWTransaction() + rwtxn, _ := db.RWTx() b := rwtxn.Bucket("widgets") b.Put([]byte("foo"), []byte("baz")) rwtxn.Rollback() |