groupstore

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

GroupStore 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_GROUP_ID = "group_id"
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_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 GROUP_STATUS_ACTIVE = "active"
View Source
const GROUP_STATUS_DELETED = "deleted"
View Source
const GROUP_STATUS_INACTIVE = "inactive"

Variables

This section is empty.

Functions

This section is empty.

Types

type EntityGroupInterface

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

	IsSoftDeleted() bool

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

	EntityType() string
	SetEntityType(entityType string) EntityGroupInterface

	EntityID() string
	SetEntityID(entityID string) EntityGroupInterface

	ID() string
	SetID(id string) EntityGroupInterface

	Memo() string
	SetMemo(memo string) EntityGroupInterface

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

	GroupID() string
	SetGroupID(groupID string) EntityGroupInterface

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

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

func NewEntityGroup

func NewEntityGroup() EntityGroupInterface

func NewEntityGroupFromExistingData

func NewEntityGroupFromExistingData(data map[string]string) EntityGroupInterface

type EntityGroupQueryInterface

type EntityGroupQueryInterface interface {
	Validate() error

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

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) EntityGroupQueryInterface

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

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

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

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

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

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

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

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

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

	HasGroupID() bool
	GroupID() string
	SetGroupID(groupID string) EntityGroupQueryInterface

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

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

func NewEntityGroupQuery

func NewEntityGroupQuery() EntityGroupQueryInterface

type GroupInterface

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

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

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

	Handle() string
	SetHandle(handle string) GroupInterface

	ID() string
	SetID(id string) GroupInterface

	Memo() string
	SetMemo(memo string) GroupInterface

	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) GroupInterface

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

	Title() string
	SetTitle(title string) GroupInterface

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

func NewGroup

func NewGroup() GroupInterface

func NewGroupFromExistingData

func NewGroupFromExistingData(data map[string]string) GroupInterface

type GroupQueryInterface

type GroupQueryInterface interface {
	Validate() error

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

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) GroupQueryInterface

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

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

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

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

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

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

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

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

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

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) GroupQueryInterface

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

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

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

func NewGroupQuery

func NewGroupQuery() GroupQueryInterface

type NewStoreOptions

type NewStoreOptions struct {
	// GroupTableName is the name of the group table
	GroupTableName string

	// EntityGroupTableName is the name of the entity to group relation table
	EntityGroupTableName 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 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

	// GroupCount returns the number of groups based on the given query options
	GroupCount(ctx context.Context, options GroupQueryInterface) (int64, error)

	// GroupCreate creates a new group
	GroupCreate(ctx context.Context, group GroupInterface) error

	// GroupDelete deletes a group
	GroupDelete(ctx context.Context, group GroupInterface) error

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

	// GroupFindByHandle returns a group by its handle
	GroupFindByHandle(ctx context.Context, handle string) (GroupInterface, error)

	// GroupFindByID returns a group by its ID
	GroupFindByID(ctx context.Context, id string) (GroupInterface, error)

	// GroupList returns a list of groups based on the given query options
	GroupList(ctx context.Context, query GroupQueryInterface) ([]GroupInterface, error)

	// GroupSoftDelete soft deletes a group
	GroupSoftDelete(ctx context.Context, group GroupInterface) error

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

	// GroupUpdate updates a group
	GroupUpdate(ctx context.Context, group GroupInterface) error

	// EntityGroupCount returns the number of group entities mappings based on the given query options
	EntityGroupCount(ctx context.Context, options EntityGroupQueryInterface) (int64, error)

	// EntityGroupCreate creates a new group entity mapping
	EntityGroupCreate(ctx context.Context, entityGroup EntityGroupInterface) error

	// EntityGroupDelete deletes a group entity mapping
	EntityGroupDelete(ctx context.Context, entityGroup EntityGroupInterface) error

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

	// EntityGroupFindByEntityAndGroup returns a group entity mapping by its entity type, entity ID and group ID
	EntityGroupFindByEntityAndGroup(ctx context.Context, entityType string, entityID string, groupID string) (EntityGroupInterface, error)

	// EntityGroupFindByID returns a group entity mapping by its ID
	EntityGroupFindByID(ctx context.Context, id string) (EntityGroupInterface, error)

	// EntityGroupList returns a list of group entity mappings based on the given query options
	EntityGroupList(ctx context.Context, query EntityGroupQueryInterface) ([]EntityGroupInterface, error)

	// EntityGroupSoftDelete soft deletes a group entity mapping
	EntityGroupSoftDelete(ctx context.Context, entityGroup EntityGroupInterface) error

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

	// EntityGroupUpdate updates a group entity mapping
	EntityGroupUpdate(ctx context.Context, entityGroup EntityGroupInterface) 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

	Group() string
	SetGroup(group 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