casbin / casbin-pg-adapter

A go-pg adapter for casbin
https://github.com/casbin/casbin
Apache License 2.0
38 stars 28 forks source link

Custom database names #12

Closed PhilippSeitz closed 4 years ago

PhilippSeitz commented 4 years ago

Hello, great Adapter! but why does the database has to be called casbin? Makes it hard to use in a managed service environment

https://github.com/casbin/casbin-pg-adapter/blob/56c866ff405eb7083188cced8a82bc7f8b5408f9/adapter.go#L104

hsluoyz commented 4 years ago

@PhilippSeitz it's just for simplicity. Can you make a PR to make it customizable?

PhilippSeitz commented 4 years ago

took a deeper look into the code and saw that it's already possible. I just had to use the pgadapter.NewAdapterByDB(db) instead.

for example:

    opts, _ := pg.ParseURL("postgresql://username:password@postgres:5432/database?sslmode=disable")
    db := pg.Connect(opts)
    a, err := pgadapter.NewAdapterByDB(db)

@hsluoyz i can add the example to the readme.

hsluoyz commented 4 years ago

Sure. Please add it. Thanks!