db

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect string
const (
	DialectPostgres Dialect = "postgres"
	DialectMySQL    Dialect = "mysql"
)

type Option

type Option func(*Store)

func WithDialect

func WithDialect(dialect Dialect) Option

func WithNow

func WithNow(now func() time.Time) Option

type Store

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

Store is a database/sql backed IAM directory. It intentionally does not expose Casdoor object structs or provider SDKs to business code. Wire it from dbx by using dbx.DB.GORM(ctx).DB() in boot/server code, but keep business code on iamx.Service.

func New

func New(database *sql.DB, opts ...Option) (*Store, error)

func (*Store) AddMembership

func (s *Store) AddMembership(ctx context.Context, m iamx.Membership) error

func (*Store) AutoMigrate

func (s *Store) AutoMigrate(ctx context.Context) error

func (*Store) CreateGroup

func (s *Store) CreateGroup(ctx context.Context, g iamx.Group) (iamx.Group, error)

func (*Store) CreateOrganization

func (s *Store) CreateOrganization(ctx context.Context, org iamx.Organization) (iamx.Organization, error)

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, user iamx.User) (iamx.User, error)

func (*Store) DeleteGroup

func (s *Store) DeleteGroup(ctx context.Context, orgID, groupID string) error

func (*Store) DeleteOrganization

func (s *Store) DeleteOrganization(ctx context.Context, orgID string) error

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, orgID, userID string) error

func (*Store) DisableUser

func (s *Store) DisableUser(ctx context.Context, orgID, userID string) error

func (*Store) GetGroup

func (s *Store) GetGroup(ctx context.Context, orgID, groupID string) (iamx.Group, error)

func (*Store) GetOrganization

func (s *Store) GetOrganization(ctx context.Context, orgID string) (iamx.Organization, error)

func (*Store) GetUser

func (s *Store) GetUser(ctx context.Context, orgID, userID string) (iamx.User, error)

func (*Store) ListEffectiveMemberships

func (s *Store) ListEffectiveMemberships(ctx context.Context, orgID, userID string) ([]iamx.Membership, error)

func (*Store) ListGroupAncestors

func (s *Store) ListGroupAncestors(ctx context.Context, orgID, groupID string) ([]iamx.Group, error)

func (*Store) ListGroupDescendants

func (s *Store) ListGroupDescendants(ctx context.Context, orgID, groupID string) ([]iamx.Group, error)

func (*Store) ListGroups

func (s *Store) ListGroups(ctx context.Context, q iamx.GroupQuery) ([]iamx.Group, error)

func (*Store) ListMemberships

func (s *Store) ListMemberships(ctx context.Context, orgID, userID string) ([]iamx.Membership, error)

func (*Store) ListOrganizations

func (s *Store) ListOrganizations(ctx context.Context, q iamx.OrganizationQuery) ([]iamx.Organization, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context, q iamx.UserQuery) ([]iamx.User, error)

func (*Store) RemoveMembership

func (s *Store) RemoveMembership(ctx context.Context, orgID, groupID, userID string) error

func (*Store) UpdateGroup

func (s *Store) UpdateGroup(ctx context.Context, g iamx.Group) (iamx.Group, error)

func (*Store) UpdateOrganization

func (s *Store) UpdateOrganization(ctx context.Context, org iamx.Organization) (iamx.Organization, error)

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, user iamx.User) (iamx.User, error)

func (*Store) UpsertGroup

func (s *Store) UpsertGroup(ctx context.Context, g iamx.Group) (iamx.Group, error)

func (*Store) UpsertOrganization

func (s *Store) UpsertOrganization(ctx context.Context, org iamx.Organization) (iamx.Organization, error)

func (*Store) UpsertUser

func (s *Store) UpsertUser(ctx context.Context, user iamx.User) (iamx.User, error)

Jump to

Keyboard shortcuts

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