Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
C
casbin-pg-adapter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abby Cin
casbin-pg-adapter
Commits
91dd054e
Commit
91dd054e
authored
Feb 15, 2020
by
Dasio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New construct method for creating adapter from existing DB connection
parent
88e55925
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
3 deletions
+10
-3
adapter.go
adapter.go
+10
-0
go.mod
go.mod
+0
-1
go.sum
go.sum
+0
-2
No files found.
adapter.go
View file @
91dd054e
...
...
@@ -56,6 +56,16 @@ func NewAdapter(arg interface{}) (*Adapter, error) {
return
a
,
nil
}
// NewAdapterByDB creates new Adapter by using existing DB connection
// creates table from CasbinRule struct if it doesn't exist
func
NewAdapterByDB
(
db
*
pg
.
DB
)
(
*
Adapter
,
error
)
{
a
:=
&
Adapter
{
db
:
db
}
if
err
:=
a
.
createTable
();
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"pgadapter.NewAdapter: %v"
,
err
)
}
return
a
,
nil
}
func
createCasbinDatabase
(
arg
interface
{})
(
*
pg
.
DB
,
error
)
{
var
opts
*
pg
.
Options
var
err
error
...
...
go.mod
View file @
91dd054e
...
...
@@ -3,7 +3,6 @@ module github.com/casbin/casbin-pg-adapter
go 1.12
require (
github.com/casbin/casbin v1.9.1
github.com/casbin/casbin/v2 v2.1.2
github.com/go-pg/pg/v9 v9.1.0
github.com/mmcloughlin/meow v0.0.0-20181112033425-871e50784daf
...
...
go.sum
View file @
91dd054e
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/casbin/casbin v1.9.1 h1:ucjbS5zTrmSLtH4XogqOG920Poe6QatdXtz1FEbApeM=
github.com/casbin/casbin v1.9.1/go.mod h1:z8uPsfBJGUsnkagrt3G8QvjgTKFMBJ32UP8HpZllfog=
github.com/casbin/casbin/v2 v2.1.2 h1:bTwon/ECRx9dwBy2ewRVr5OiqjeXSGiTUY74sDPQi/g=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/codemodus/kace v0.5.1 h1:4OCsBlE2c/rSJo375ggfnucv9eRzge/U5LrrOZd47HA=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment