rolestore

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

README

RoleStore Open in Gitpod

Tests Status Go Report Card PkgGoDev

UserStore is a robust user management package.

Supports multiple database storages (SQLite, MySQL, or PostgreSQL)

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/agpl-3.0.en.html

For commercial use, please use my contact page to obtain a commercial license.

Documentation

Index

Constants

View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_ENTITY_ID = "entity_id"
View Source
const COLUMN_ENTITY_TYPE = "entity_type"
View Source
const COLUMN_HANDLE = "handle"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_MEMO = "memo"
View Source
const COLUMN_METAS = "metas"
View Source
const COLUMN_ROLE = "role"
View Source
const COLUMN_ROLE_ID = "role_id"
View Source
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
View Source
const COLUMN_STATUS = "status"
View Source
const COLUMN_TITLE = "title"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const ERROR_EMPTY_ARRAY = "array cannot be empty"
View Source
const ERROR_EMPTY_STRING = "string cannot be empty"
View Source
const ERROR_NEGATIVE_NUMBER = "number cannot be negative"
View Source
const ROLE_STATUS_ACTIVE = "active"
View Source
const ROLE_STATUS_DELETED = "deleted"
View Source
const ROLE_STATUS_INACTIVE = "inactive"

Variables

This section is empty.

Functions

This section is empty.

Types

type EntityRoleInterface

type EntityRoleInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	IsSoftDeleted() bool

	CreatedAt() string
	CreatedAtCarbon() carbon.Carbon
	SetCreatedAt(createdAt string) EntityRoleInterface

	EntityType() string
	SetEntityType(entityType string) EntityRoleInterface

	EntityID() string
	SetEntityID(entityID string) EntityRoleInterface

	ID() string
	SetID(id string) EntityRoleInterface

	Memo() string
	SetMemo(memo string) EntityRoleInterface

	Meta(name string) string
	SetMeta(name string, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error

	RoleID() string
	SetRoleID(roleID string) EntityRoleInterface

	SoftDeletedAt() string
	SoftDeletedAtCarbon() carbon.Carbon
	SetSoftDeletedAt(softDeletedAt string) EntityRoleInterface

	UpdatedAt() string
	UpdatedAtCarbon() carbon.Carbon
	SetUpdatedAt(updatedAt string) EntityRoleInterface
}

func NewEntityRole

func NewEntityRole() EntityRoleInterface

func NewEntityRoleFromExistingData

func NewEntityRoleFromExistingData(data map[string]string) EntityRoleInterface

type EntityRoleQueryInterface

type EntityRoleQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) EntityRoleQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) EntityRoleQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) EntityRoleQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) EntityRoleQueryInterface

	HasEntityID() bool
	EntityID() string
	SetEntityID(entityID string) EntityRoleQueryInterface

	HasEntityType() bool
	EntityType() string
	SetEntityType(entityType string) EntityRoleQueryInterface

	HasID() bool
	ID() string
	SetID(id string) EntityRoleQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) EntityRoleQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) EntityRoleQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) EntityRoleQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) EntityRoleQueryInterface

	HasRoleID() bool
	RoleID() string
	SetRoleID(roleID string) EntityRoleQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) EntityRoleQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) EntityRoleQueryInterface
	// contains filtered or unexported methods
}

func NewEntityRoleQuery

func NewEntityRoleQuery() EntityRoleQueryInterface

type NewStoreOptions

type NewStoreOptions struct {
	// RoleTableName is the name of the role table
	RoleTableName string

	// EntityRoleTableName is the name of the entity to role relation table
	EntityRoleTableName string

	// DB is the underlying database connection
	DB *sql.DB

	// DbDriverName is the database driver name/type
	DbDriverName string

	// AutomigrateEnabled indicates whether to automatically migrate the database
	AutomigrateEnabled bool

	// DebugEnabled enables or disables the debug mode
	DebugEnabled bool

	// SqlLogger is the sql statement logger when debug mode is enabled, defaults to the default logger
	SqlLogger *slog.Logger
}

NewStoreOptions define the options for creating a new block store

type RoleInterface

type RoleInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	IsActive() bool
	IsInactive() bool
	IsSoftDeleted() bool

	CreatedAt() string
	CreatedAtCarbon() carbon.Carbon
	SetCreatedAt(createdAt string) RoleInterface

	Handle() string
	SetHandle(handle string) RoleInterface

	ID() string
	SetID(id string) RoleInterface

	Memo() string
	SetMemo(memo string) RoleInterface

	Meta(name string) string
	SetMeta(name string, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error

	Status() string
	SetStatus(status string) RoleInterface

	SoftDeletedAt() string
	SoftDeletedAtCarbon() carbon.Carbon
	SetSoftDeletedAt(softDeletedAt string) RoleInterface

	Title() string
	SetTitle(title string) RoleInterface

	UpdatedAt() string
	UpdatedAtCarbon() carbon.Carbon
	SetUpdatedAt(updatedAt string) RoleInterface
}

func NewRole

func NewRole() RoleInterface

func NewRoleFromExistingData

func NewRoleFromExistingData(data map[string]string) RoleInterface

type RoleQueryInterface

type RoleQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) RoleQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) RoleQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) RoleQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) RoleQueryInterface

	HasHandle() bool
	Handle() string
	SetHandle(handle string) RoleQueryInterface

	HasID() bool
	ID() string
	SetID(id string) RoleQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) RoleQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) RoleQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) RoleQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) RoleQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) RoleQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) RoleQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) RoleQueryInterface

	HasStatusIn() bool
	StatusIn() []string
	SetStatusIn(statusIn []string) RoleQueryInterface

	HasTitleLike() bool
	TitleLike() string
	SetTitleLike(titleLike string) RoleQueryInterface
	// contains filtered or unexported methods
}

func NewRoleQuery

func NewRoleQuery() RoleQueryInterface

type StoreInterface

type StoreInterface interface {
	// AutoMigrate auto migrates the database schema
	AutoMigrate() error

	// EnableDebug enables or disables the debug mode
	EnableDebug(debug bool)

	// DB returns the underlying database connection
	DB() *sql.DB

	// RoleCount returns the number of roles based on the given query options
	RoleCount(ctx context.Context, options RoleQueryInterface) (int64, error)

	// RoleCreate creates a new role
	RoleCreate(ctx context.Context, role RoleInterface) error

	// RoleDelete deletes a role
	RoleDelete(ctx context.Context, role RoleInterface) error

	// RoleDeleteByID deletes a role by its ID
	RoleDeleteByID(ctx context.Context, id string) error

	// RoleFindByHandle returns a role by its handle
	RoleFindByHandle(ctx context.Context, handle string) (RoleInterface, error)

	// RoleFindByID returns a role by its ID
	RoleFindByID(ctx context.Context, id string) (RoleInterface, error)

	// RoleList returns a list of roles based on the given query options
	RoleList(ctx context.Context, query RoleQueryInterface) ([]RoleInterface, error)

	// RoleSoftDelete soft deletes a role
	RoleSoftDelete(ctx context.Context, role RoleInterface) error

	// RoleSoftDeleteByID soft deletes a role by its ID
	RoleSoftDeleteByID(ctx context.Context, id string) error

	// RoleUpdate updates a role
	RoleUpdate(ctx context.Context, role RoleInterface) error

	// EntityRoleCount returns the number of role entities mappings based on the given query options
	EntityRoleCount(ctx context.Context, options EntityRoleQueryInterface) (int64, error)

	// EntityRoleCreate creates a new role entity mapping
	EntityRoleCreate(ctx context.Context, entityRole EntityRoleInterface) error

	// EntityRoleDelete deletes a role entity mapping
	EntityRoleDelete(ctx context.Context, entityRole EntityRoleInterface) error

	// EntityRoleDeleteByID deletes a role entity mapping by its ID
	EntityRoleDeleteByID(ctx context.Context, id string) error

	// EntityRoleFindByEntityAndRole returns a role entity mapping by its entity type, entity ID and role ID
	EntityRoleFindByEntityAndRole(ctx context.Context, entityType string, entityID string, roleID string) (EntityRoleInterface, error)

	// EntityRoleFindByID returns a role entity mapping by its ID
	EntityRoleFindByID(ctx context.Context, id string) (EntityRoleInterface, error)

	// EntityRoleList returns a list of role entity mappings based on the given query options
	EntityRoleList(ctx context.Context, query EntityRoleQueryInterface) ([]EntityRoleInterface, error)

	// EntityRoleSoftDelete soft deletes a role entity mapping
	EntityRoleSoftDelete(ctx context.Context, entityRole EntityRoleInterface) error

	// EntityRoleSoftDeleteByID soft deletes a role entity mapping by its ID
	EntityRoleSoftDeleteByID(ctx context.Context, id string) error

	// EntityRoleUpdate updates a role entity mapping
	EntityRoleUpdate(ctx context.Context, entityRole EntityRoleInterface) error
}

func NewStore

func NewStore(opts NewStoreOptions) (StoreInterface, error)

NewStore creates a new block store

type UserInterface

type UserInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()
	Get(columnName string) string
	Set(columnName string, value string)

	IsActive() bool
	IsInactive() bool
	IsSoftDeleted() bool
	IsUnverified() bool

	IsAdministrator() bool
	IsManager() bool
	IsSuperuser() bool

	IsRegistrationCompleted() bool

	BusinessName() string
	SetBusinessName(businessName string) UserInterface

	Country() string
	SetCountry(country string) UserInterface

	CreatedAt() string
	CreatedAtCarbon() carbon.Carbon
	SetCreatedAt(createdAt string) UserInterface

	Email() string
	SetEmail(email string) UserInterface

	ID() string
	SetID(id string) UserInterface

	FirstName() string
	SetFirstName(firstName string) UserInterface

	LastName() string
	SetLastName(lastName string) UserInterface

	Memo() string
	SetMemo(memo string) UserInterface

	Meta(name string) string
	SetMeta(name string, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error
	UpsertMetas(metas map[string]string) error

	MiddleNames() string
	SetMiddleNames(middleNames string) UserInterface

	Password() string
	SetPassword(password string) UserInterface

	Phone() string
	SetPhone(phone string) UserInterface

	ProfileImageUrl() string
	SetProfileImageUrl(profileImageUrl string) UserInterface

	Role() string
	SetRole(role string) UserInterface

	SoftDeletedAt() string
	SoftDeletedAtCarbon() carbon.Carbon
	SetSoftDeletedAt(deletedAt string) UserInterface

	Timezone() string
	SetTimezone(timezone string) UserInterface

	Status() string
	SetStatus(status string) UserInterface

	PasswordCompare(password string) bool

	UpdatedAt() string
	UpdatedAtCarbon() carbon.Carbon
	SetUpdatedAt(updatedAt string) UserInterface
}

Jump to

Keyboard shortcuts

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