sqlcadapter

package module
v0.0.0-...-b698091 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2023 License: MIT Imports: 9 Imported by: 0

README

sqlc-adapter

github.com/zeromicro/go-zero/core/stores/sqlc Adapter for casbin

Documentation

Index

Constants

View Source
const (
	PolicyKey = "casbin:policy"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapte

type Adapte interface {
	// LoadPolicy loads all policy rules from the storage.
	LoadPolicy(model model.Model) error
	// SavePolicy saves all policy rules to the storage.
	SavePolicy(model model.Model) error

	// AddPolicy adds a policy rule to the storage.
	// This is part of the Auto-Save feature.
	AddPolicy(sec string, ptype string, rule []string) error
	// RemovePolicy removes a policy rule from the storage.
	// This is part of the Auto-Save feature.
	RemovePolicy(sec string, ptype string, rule []string) error
	// RemoveFilteredPolicy removes policy rules that match the filter from the storage.
	// This is part of the Auto-Save feature.
	RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
}

Adapter is the interface for Casbin adapters.

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

func NewAdapter

func NewAdapter(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *Adapter

func (*Adapter) LoadPolicy

func (a *Adapter) LoadPolicy(model model.Model) (err error)

LoadPolicy loads all policy rules from the storage.

func (*Adapter) SelectRow

func (a *Adapter) SelectRow() (*CasbinRule, error)

func (*Adapter) SelectRows

func (a *Adapter) SelectRows() ([]*CasbinRule, error)

type CasbinRule

type CasbinRule struct {
	Id    int64  `db:"id"`
	Ptype string `db:"ptype"`
	V0    string `db:"v0"`
	V1    string `db:"v1"`
	V2    string `db:"v2"`
	V3    string `db:"v3"`
	V4    string `db:"v4"`
	V5    string `db:"v5"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL