Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippSeitz committed Jul 4, 2020
1 parent 56c866f commit 841f1fd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,31 @@ func main() {
}
```

## Custom DB Connection

You can provide a custom table or database name with `pgadapter.NewAdapterByDB`

```go
package main

import (
"github.com/casbin/casbin/v2"
pgadapter "github.com/casbin/casbin-pg-adapter"
"github.com/go-pg/pg/v9"
)

func main() {
opts, _ := pg.ParseURL("postgresql://pguser:pgpassword@localhost:5432/pgdb?sslmode=disable")

db := pg.Connect(opts)
defer db.Close()

a, _ := pgadapter.NewAdapterByDB(db, pgadapter.WithTableName("custom_table"))
e, _ := casbin.NewEnforcer("examples/rbac_model.conf", a)
...
}
```

## Run all tests

docker-compose run --rm go
Expand Down

0 comments on commit 841f1fd

Please sign in to comment.