Skip to content

Commit

Permalink
update the README
Browse files Browse the repository at this point in the history
  • Loading branch information
andizzle committed Nov 8, 2017
1 parent 2e27d91 commit e945901
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ db, err := rwdb.Open("driver", conns...)

Query a database rotate the use of database connections

### Basic usage

```go
db, err := rwdb.Open("driver", conns...)

Expand Down Expand Up @@ -68,6 +70,8 @@ Sticky can be turned off
db.SetSticky(false)
```

### A more practical example

The db is marked as modified if there's a successful `Write` to the databse, which turns on the sticky logic.
However, the real world usecase would require `modified` value to be reset on each request session.

Expand All @@ -77,8 +81,8 @@ Here's what we can do:
db, err := rwdb.Open("driver", conns...)

func RecordUserLogin() {
d := db.New() // This will make sure the following read are not affected by
// other sessions' write action
d := db.New() // This will make sure the following read are not affected by
// other sessions' write action

d.Query("SELECT * from `users` where id = ?")
...
Expand Down

0 comments on commit e945901

Please sign in to comment.