userstore

package module
v1.22.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: GPL-3.0 Imports: 16 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

UserStore

Tests Status Go Report Card PkgGoDev

UserStore is a robust user management package.

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

Features

  • User, Role, and Group management
  • Soft delete support
  • Meta data storage for custom fields
  • Password hashing and verification
  • Method chaining for fluent API
  • Transaction support
  • Query builder for complex searches

Documentation

View the complete documentation at: https://htmlpreview.github.io/?https://raw.githubusercontent.com/dracory/userstore/main/docs/index.html

License

This project is licensed under the GNU General Public License version 3 (GPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/gpl-3.0.en.html

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

Installation

go get github.com/dracory/userstore

Setup

userStore, err = userstore.NewStore(userstore.NewStoreOptions{
	DB:                 databaseInstance,
    UserTableName:      "user",
	RoleTableName:      "role",       // required when RolesEnabled is true
	UserRoleTableName:  "user_role",  // required when RolesEnabled is true
	RolesEnabled:       true,
	GroupTableName:     "group",      // required when GroupsEnabled is true
	UserGroupTableName: "user_group", // required when GroupsEnabled is true
	GroupsEnabled:      true,
	AutomigrateEnabled: true,
	DebugEnabled:       false,
})

if err != nil {
	return errors.Join(errors.New("userstore.NewStore"), err)
}

API Convention

All getter methods use the Get prefix and all setter methods use the Set prefix:

  • Getters: GetID(), GetName(), GetEmail(), GetStatus(), etc.
  • Setters: SetID(), SetName(), SetEmail(), SetStatus(), etc.

Examples

Creating a User
user := userstore.NewUser().
    SetStatus(userstore.USER_STATUS_ACTIVE).
    SetFirstName("John").
    SetLastName("Doe").
    SetEmail("test@test.com")

err := userStore.UserCreate(context.Background(), user)

if err != nil {
	return errors.New("user failed to create")
}
Reading User Properties
id := user.GetID()
email := user.GetEmail()
firstName := user.GetFirstName()
lastName := user.GetLastName()
status := user.GetStatus()
Creating a Role
role := userstore.NewRole().
    SetName("Administrator").
    SetHandle("admin").
    SetStatus(userstore.ROLE_STATUS_ACTIVE)

err := userStore.RoleCreate(context.Background(), role)

if err != nil {
	return errors.New("role failed to create")
}
Assigning a Role to a User
userRole := userstore.NewUserRole().
    SetUserID(user.GetID()).
    SetRoleID(role.GetID())

err := userStore.UserRoleCreate(context.Background(), userRole)

if err != nil {
	return errors.New("user role failed to create")
}

// Or find-or-create the assignment
userRole, err := userStore.UserRoleFindByUserIDAndRoleIDOrCreate(
    context.Background(), user.GetID(), role.GetID())

// List a user's roles
roles, err := userStore.UserRoles(context.Background(), user.GetID())

// Check if a user has one or more roles (all must match)
hasRoles, err := userStore.UserHasRoles(
    context.Background(), user.GetID(), []string{role.GetID()})
Creating a Group
group := userstore.NewGroup().
    SetName("Staff").
    SetHandle("staff").
    SetStatus(userstore.GROUP_STATUS_ACTIVE)

err := userStore.GroupCreate(context.Background(), group)

if err != nil {
	return errors.New("group failed to create")
}
Adding a User to a Group
userGroup := userstore.NewUserGroup().
    SetUserID(user.GetID()).
    SetGroupID(group.GetID())

err := userStore.UserGroupCreate(context.Background(), userGroup)

if err != nil {
	return errors.New("user group failed to create")
}

// Or find-or-create the membership
userGroup, err := userStore.UserGroupFindByUserIDAndGroupIDOrCreate(
    context.Background(), user.GetID(), group.GetID())

// List a user's groups
groups, err := userStore.UserGroups(context.Background(), user.GetID())

// Check if a user belongs to one or more groups (all must match)
isMember, err := userStore.UserHasGroups(
    context.Background(), user.GetID(), []string{group.GetID()})
Finding Users
// Find by ID
user, err := userStore.UserFindByID(context.Background(), userID)

// List users with query
query := userstore.NewUserQuery().
    SetStatus(userstore.USER_STATUS_ACTIVE).
    SetLimit(10)

users, err := userStore.UserList(context.Background(), query)
Updating Users
user.SetFirstName("Jane")
user.SetEmail("jane@example.com")

err := userStore.UserUpdate(context.Background(), user)
Soft Deleting Users
err := userStore.UserSoftDelete(context.Background(), user)

Runnable Examples

See the examples/ directory for complete runnable programs:

  • examples/basic — creating, finding, updating, and soft deleting users
  • examples/roles — creating roles and assigning them to users
  • examples/groups — creating groups and managing memberships

Run any of them with:

go run ./examples/basic

Documentation

Index

Constants

View Source
const COLUMN_BUSINESS_NAME = "business_name"
View Source
const COLUMN_COUNTRY = "country"
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_EMAIL = "email"
View Source
const COLUMN_FIRST_NAME = "first_name"
View Source
const COLUMN_GROUP_ID = "group_id"
View Source
const COLUMN_HANDLE = "handle"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_LAST_NAME = "last_name"
View Source
const COLUMN_MEMO = "memo"
View Source
const COLUMN_METAS = "metas"
View Source
const COLUMN_MIDDLE_NAMES = "middle_names"
View Source
const COLUMN_NAME = "name"
View Source
const COLUMN_PASSWORD = "password"
View Source
const COLUMN_PHONE = "phone"
View Source
const COLUMN_PROFILE_IMAGE_URL = "profile_image_url"
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_TIMEZONE = "timezone"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const COLUMN_USER_ID = "user_id"
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"
View Source
const MAX_DATETIME = "9999-12-31 23:59:59"

MAX_DATETIME is a far-future datetime used as the default soft-delete sentinel.

View Source
const ROLE_STATUS_ACTIVE = "active"
View Source
const ROLE_STATUS_DELETED = "deleted"
View Source
const ROLE_STATUS_INACTIVE = "inactive"
View Source
const SORT_ORDER_ASC = "asc"
View Source
const SORT_ORDER_DESC = "desc"
View Source
const USER_ROLE_ADMINISTRATOR = "administrator"
View Source
const USER_ROLE_MANAGER = "manager"
View Source
const USER_ROLE_SUPERUSER = "superuser"
View Source
const USER_ROLE_USER = "user"
View Source
const USER_STATUS_ACTIVE = "active"
View Source
const USER_STATUS_DELETED = "deleted"
View Source
const USER_STATUS_INACTIVE = "inactive"
View Source
const USER_STATUS_UNVERIFIED = "unverified"

Variables

This section is empty.

Functions

func RoleNoImageUrl

func RoleNoImageUrl() string

func UserNoImageUrl

func UserNoImageUrl() string

Types

type GroupInterface added in v1.20.0

type GroupInterface interface {

	// Data returns all fields as a map
	Data() map[string]string
	// DataChanged returns the changed fields as a map
	DataChanged() map[string]string
	// MarkAsNotDirty marks all fields as not changed
	MarkAsNotDirty()
	// ToMap returns a DB-ready map of the group
	ToMap() map[string]any

	// IsActive returns true if the group is active
	IsActive() bool
	// IsInactive returns true if the group is inactive
	IsInactive() bool
	// IsSoftDeleted returns true if the group is soft deleted
	IsSoftDeleted() bool

	// GetCreatedAt returns the created at datetime
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the created at datetime as carbon
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the created at datetime
	SetCreatedAt(createdAt string) GroupInterface

	// GetHandle returns the handle
	GetHandle() string
	// SetHandle sets the handle
	SetHandle(handle string) GroupInterface

	// GetID returns the ID
	GetID() string
	// SetID sets the ID
	SetID(id string) GroupInterface

	// GetName returns the name
	GetName() string
	// SetName sets the name
	SetName(name string) GroupInterface

	// GetMemo returns the memo
	GetMemo() string
	// SetMemo sets the memo
	SetMemo(memo string) GroupInterface

	// GetMeta returns the value of the meta with the given name
	GetMeta(name string) string
	// SetMeta sets the value of the meta with the given name
	SetMeta(name string, value string) error
	// GetMetas returns all metas
	GetMetas() (map[string]string, error)
	// SetMetas sets all metas, overwriting existing ones
	SetMetas(metas map[string]string) error
	// UpsertMetas merges the given metas with the existing ones
	UpsertMetas(metas map[string]string) error

	// GetStatus returns the status
	GetStatus() string
	// SetStatus sets the status
	SetStatus(status string) GroupInterface

	// GetSoftDeletedAt returns the soft deleted at datetime
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deleted at datetime as carbon
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deleted at datetime
	SetSoftDeletedAt(softDeletedAt string) GroupInterface

	// GetUpdatedAt returns the updated at datetime
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the updated at datetime as carbon
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the updated at datetime
	SetUpdatedAt(updatedAt string) GroupInterface
}

GroupInterface defines the interface for a group

func NewGroup added in v1.20.0

func NewGroup() GroupInterface

func NewGroupFromExistingData added in v1.20.0

func NewGroupFromExistingData(data map[string]string) GroupInterface

type GroupQueryInterface added in v1.20.0

type GroupQueryInterface interface {
	// Validate validates the query
	Validate() error

	// Columns returns the columns to return from the database
	Columns() []string
	// SetColumns sets the columns to return from the database
	SetColumns(columns []string) GroupQueryInterface

	// HasCountOnly returns true if the query is for counting only
	HasCountOnly() bool
	// IsCountOnly returns true if the query is for counting only
	IsCountOnly() bool
	// SetCountOnly sets the query to count only
	SetCountOnly(countOnly bool) GroupQueryInterface

	// HasHandle returns true if the query has a handle
	HasHandle() bool
	// Handle returns the handle
	Handle() string
	// SetHandle sets the handle
	SetHandle(handle string) GroupQueryInterface

	// HasID returns true if the query has an ID
	HasID() bool
	// GetID returns the ID
	GetID() string
	// SetID sets the ID
	SetID(id string) GroupQueryInterface

	// HasIDIn returns true if the query has an ID in
	HasIDIn() bool
	// IDIn returns the ID in
	IDIn() []string
	// SetIDIn sets the ID in
	SetIDIn(idIn []string) GroupQueryInterface

	// HasLimit returns true if the query has a limit
	HasLimit() bool
	// Limit returns the limit
	Limit() int
	// SetLimit sets the limit
	SetLimit(limit int) GroupQueryInterface

	// HasOffset returns true if the query has an offset
	HasOffset() bool
	// Offset returns the offset
	Offset() int
	// SetOffset sets the offset
	SetOffset(offset int) GroupQueryInterface

	// HasOrderBy returns true if the query has an order by
	HasOrderBy() bool
	// OrderBy returns the order by
	OrderBy() string
	// SetOrderBy sets the order by
	SetOrderBy(orderBy string) GroupQueryInterface

	// HasSortDirection returns true if the query has a sort direction
	HasSortDirection() bool
	// SortDirection returns the sort direction
	SortDirection() string
	// SetSortDirection sets the sort direction
	SetSortDirection(sortDirection string) GroupQueryInterface

	// HasSoftDeletedIncluded returns true if the query has soft deleted included
	HasSoftDeletedIncluded() bool
	// SoftDeletedIncluded returns the soft deleted included
	SoftDeletedIncluded() bool
	// SetSoftDeletedIncluded sets the soft deleted included
	SetSoftDeletedIncluded(softDeletedIncluded bool) GroupQueryInterface

	// HasStatus returns true if the query has a status
	HasStatus() bool
	// Status returns the status
	Status() string
	// SetStatus sets the status
	SetStatus(status string) GroupQueryInterface

	// HasTitleLike returns true if the query has a title like
	HasTitleLike() bool
	// TitleLike returns the title like
	TitleLike() string
	// SetTitleLike sets the title like
	SetTitleLike(titleLike string) GroupQueryInterface
	// contains filtered or unexported methods
}

GroupQueryInterface defines the interface for group queries

func NewGroupQuery added in v1.20.0

func NewGroupQuery() GroupQueryInterface

type NewStoreOptions

type NewStoreOptions struct {
	// Table names
	UserTableName      string
	RolesEnabled       bool
	RoleTableName      string
	UserRoleTableName  string
	GroupsEnabled      bool
	GroupTableName     string
	UserGroupTableName string

	// Database
	DB *sql.DB

	// Options
	AutomigrateEnabled bool
	DebugEnabled       bool
}

NewStoreOptions define the options for creating a new user store

type RoleInterface

type RoleInterface interface {

	// Data returns all fields as a map
	Data() map[string]string
	// DataChanged returns the changed fields as a map
	DataChanged() map[string]string
	// MarkAsNotDirty marks all fields as not changed
	MarkAsNotDirty()
	// ToMap returns a DB-ready map of the role
	ToMap() map[string]any

	// IsActive returns true if the role is active
	IsActive() bool
	// IsInactive returns true if the role is inactive
	IsInactive() bool
	// IsSoftDeleted returns true if the role is soft deleted
	IsSoftDeleted() bool

	// GetCreatedAt returns the created at datetime
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the created at datetime as carbon
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the created at datetime
	SetCreatedAt(createdAt string) RoleInterface

	// GetHandle returns the handle
	GetHandle() string
	// SetHandle sets the handle
	SetHandle(handle string) RoleInterface

	// GetID returns the ID
	GetID() string
	// SetID sets the ID
	SetID(id string) RoleInterface

	// GetName returns the name
	GetName() string
	// SetName sets the name
	SetName(name string) RoleInterface

	// GetMemo returns the memo
	GetMemo() string
	// SetMemo sets the memo
	SetMemo(memo string) RoleInterface

	// GetMeta returns the value of the meta with the given name
	GetMeta(name string) string
	// SetMeta sets the value of the meta with the given name
	SetMeta(name string, value string) error
	// GetMetas returns all metas
	GetMetas() (map[string]string, error)
	// SetMetas sets all metas, overwriting existing ones
	SetMetas(metas map[string]string) error

	// GetStatus returns the status
	GetStatus() string
	// SetStatus sets the status
	SetStatus(status string) RoleInterface

	// GetSoftDeletedAt returns the soft deleted at datetime
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deleted at datetime as carbon
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deleted at datetime
	SetSoftDeletedAt(softDeletedAt string) RoleInterface

	// GetUpdatedAt returns the updated at datetime
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the updated at datetime as carbon
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the updated at datetime
	SetUpdatedAt(updatedAt string) RoleInterface
}

RoleInterface defines the interface for a role

func NewRole

func NewRole() RoleInterface

func NewRoleFromExistingData

func NewRoleFromExistingData(data map[string]string) RoleInterface

type RoleQueryInterface

type RoleQueryInterface interface {
	// Validate validates the query
	Validate() error

	// Columns returns the columns to retrurn from the database
	Columns() []string

	// SetColumns sets the columns to retrurn from the database
	SetColumns(columns []string) RoleQueryInterface

	// HasCountOnly returns true if the query is for counting only
	HasCountOnly() bool
	// IsCountOnly returns true if the query is for counting only
	IsCountOnly() bool
	// SetCountOnly sets the query to count only
	SetCountOnly(countOnly bool) RoleQueryInterface

	// HasHandle returns true if the query has a handle
	HasHandle() bool
	// Handle returns the handle
	Handle() string
	// SetHandle sets the handle
	SetHandle(handle string) RoleQueryInterface

	// HasID returns true if the query has an ID
	HasID() bool
	// GetID returns the ID
	GetID() string
	// SetID sets the ID
	SetID(id string) RoleQueryInterface

	// HasIDIn returns true if the query has an ID in
	HasIDIn() bool
	// IDIn returns the ID in
	IDIn() []string
	// SetIDIn sets the ID in
	SetIDIn(idIn []string) RoleQueryInterface

	// HasLimit returns true if the query has a limit
	HasLimit() bool
	// Limit returns the limit
	Limit() int
	// SetLimit sets the limit
	SetLimit(limit int) RoleQueryInterface

	// HasOffset returns true if the query has an offset
	HasOffset() bool
	// Offset returns the offset
	Offset() int
	// SetOffset sets the offset
	SetOffset(offset int) RoleQueryInterface

	// HasOrderBy returns true if the query has an order by
	HasOrderBy() bool
	// OrderBy returns the order by
	OrderBy() string
	// SetOrderBy sets the order by
	SetOrderBy(orderBy string) RoleQueryInterface

	// HasSortDirection returns true if the query has a sort direction
	HasSortDirection() bool
	// SortDirection returns the sort direction
	SortDirection() string
	// SetSortDirection sets the sort direction
	SetSortDirection(sortDirection string) RoleQueryInterface

	// HasSoftDeletedIncluded returns true if the query has soft deleted included
	HasSoftDeletedIncluded() bool
	// SoftDeletedIncluded returns the soft deleted included
	SoftDeletedIncluded() bool
	// SetSoftDeletedIncluded sets the soft deleted included
	SetSoftDeletedIncluded(softDeletedIncluded bool) RoleQueryInterface

	// HasStatus returns true if the query has a status
	HasStatus() bool
	// Status returns the status
	Status() string
	// SetStatus sets the status
	SetStatus(status string) RoleQueryInterface

	// HasTitleLike returns true if the query has a title like
	HasTitleLike() bool
	// TitleLike returns the title like
	TitleLike() string
	// SetTitleLike sets the title like
	SetTitleLike(titleLike string) RoleQueryInterface
	// contains filtered or unexported methods
}

RoleQueryInterface defines the interface for role queries

func NewRoleQuery

func NewRoleQuery() RoleQueryInterface

type StoreInterface

type StoreInterface interface {
	// contains filtered or unexported methods
}

StoreInterface defines the interface for the user store

func NewStore

func NewStore(opts NewStoreOptions) (StoreInterface, error)

NewStore creates a new user store

type UserGroupInterface added in v1.20.0

type UserGroupInterface interface {

	// Data returns all fields as a map
	Data() map[string]string
	// DataChanged returns the changed fields as a map
	DataChanged() map[string]string
	// MarkAsNotDirty marks all fields as not changed
	MarkAsNotDirty()
	// ToMap returns a DB-ready map of the user group
	ToMap() map[string]any

	// IsSoftDeleted returns true if the user group is soft deleted
	IsSoftDeleted() bool

	// GetCreatedAt returns the created at datetime
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the created at datetime as carbon
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the created at datetime
	SetCreatedAt(createdAt string) UserGroupInterface

	// GetID returns the ID
	GetID() string
	// SetID sets the ID
	SetID(id string) UserGroupInterface

	// GetUserID returns the user ID
	GetUserID() string
	// SetUserID sets the user ID
	SetUserID(userID string) UserGroupInterface

	// GetGroupID returns the group ID
	GetGroupID() string
	// SetGroupID sets the group ID
	SetGroupID(groupID string) UserGroupInterface

	// GetSoftDeletedAt returns the soft deleted at datetime
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deleted at datetime as carbon
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deleted at datetime
	SetSoftDeletedAt(softDeletedAt string) UserGroupInterface

	// GetUpdatedAt returns the updated at datetime
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the updated at datetime as carbon
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the updated at datetime
	SetUpdatedAt(updatedAt string) UserGroupInterface
}

UserGroupInterface defines the interface for a user group membership

func NewUserGroup added in v1.20.0

func NewUserGroup() UserGroupInterface

func NewUserGroupFromExistingData added in v1.20.0

func NewUserGroupFromExistingData(data map[string]string) UserGroupInterface

type UserGroupQueryInterface added in v1.20.0

type UserGroupQueryInterface interface {
	// Validate validates the query
	Validate() error

	// Columns returns the columns to return from the database
	Columns() []string
	// SetColumns sets the columns to return from the database
	SetColumns(columns []string) UserGroupQueryInterface

	// HasCountOnly returns true if the query is for counting only
	HasCountOnly() bool
	// IsCountOnly returns true if the query is for counting only
	IsCountOnly() bool
	// SetCountOnly sets the query to count only
	SetCountOnly(countOnly bool) UserGroupQueryInterface

	// HasID returns true if the query has an ID
	HasID() bool
	// GetID returns the ID
	GetID() string
	// SetID sets the ID
	SetID(id string) UserGroupQueryInterface

	// HasIDIn returns true if the query has an ID in
	HasIDIn() bool
	// IDIn returns the ID in
	IDIn() []string
	// SetIDIn sets the ID in
	SetIDIn(idIn []string) UserGroupQueryInterface

	// HasUserID returns true if the query has a user ID
	HasUserID() bool
	// UserID returns the user ID
	UserID() string
	// SetUserID sets the user ID
	SetUserID(userID string) UserGroupQueryInterface

	// HasUserIDIn returns true if the query has a user ID in
	HasUserIDIn() bool
	// UserIDIn returns the user ID in
	UserIDIn() []string
	// SetUserIDIn sets the user ID in
	SetUserIDIn(userIDIn []string) UserGroupQueryInterface

	// HasGroupID returns true if the query has a group ID
	HasGroupID() bool
	// GroupID returns the group ID
	GroupID() string
	// SetGroupID sets the group ID
	SetGroupID(groupID string) UserGroupQueryInterface

	// HasGroupIDIn returns true if the query has a group ID in
	HasGroupIDIn() bool
	// GroupIDIn returns the group ID in
	GroupIDIn() []string
	// SetGroupIDIn sets the group ID in
	SetGroupIDIn(groupIDIn []string) UserGroupQueryInterface

	// HasLimit returns true if the query has a limit
	HasLimit() bool
	// Limit returns the limit
	Limit() int
	// SetLimit sets the limit
	SetLimit(limit int) UserGroupQueryInterface

	// HasOffset returns true if the query has an offset
	HasOffset() bool
	// Offset returns the offset
	Offset() int
	// SetOffset sets the offset
	SetOffset(offset int) UserGroupQueryInterface

	// HasOrderBy returns true if the query has an order by
	HasOrderBy() bool
	// OrderBy returns the order by
	OrderBy() string
	// SetOrderBy sets the order by
	SetOrderBy(orderBy string) UserGroupQueryInterface

	// HasSortDirection returns true if the query has a sort direction
	HasSortDirection() bool
	// SortDirection returns the sort direction
	SortDirection() string
	// SetSortDirection sets the sort direction
	SetSortDirection(sortDirection string) UserGroupQueryInterface

	// HasSoftDeletedIncluded returns true if the query has soft deleted included
	HasSoftDeletedIncluded() bool
	// SoftDeletedIncluded returns the soft deleted included
	SoftDeletedIncluded() bool
	// SetSoftDeletedIncluded sets the soft deleted included
	SetSoftDeletedIncluded(softDeletedIncluded bool) UserGroupQueryInterface
	// contains filtered or unexported methods
}

UserGroupQueryInterface defines the interface for user group queries

func NewUserGroupQuery added in v1.20.0

func NewUserGroupQuery() UserGroupQueryInterface

type UserInterface

type UserInterface interface {

	// Data returns all fields as a map
	Data() map[string]string
	// DataChanged returns the changed fields as a map
	DataChanged() map[string]string
	// MarkAsNotDirty marks all fields as not changed
	MarkAsNotDirty()
	// Get returns the value of the specified column
	Get(columnName string) string
	// Set sets the value of the specified column
	Set(columnName string, value string)
	// ToMap returns a DB-ready map of the user
	ToMap() map[string]any

	// IsActive returns true if the user is active
	IsActive() bool
	// IsInactive returns true if the user is inactive
	IsInactive() bool
	// IsSoftDeleted returns true if the user is soft deleted
	IsSoftDeleted() bool
	// IsUnverified returns true if the user is unverified
	IsUnverified() bool

	// IsAdministrator returns true if the user has the administrator role
	IsAdministrator() bool
	// IsManager returns true if the user has the manager role
	IsManager() bool
	// IsSuperuser returns true if the user has the superuser role
	IsSuperuser() bool

	// IsRegistrationCompleted returns true if the user has completed registration
	IsRegistrationCompleted() bool

	// GetBusinessName returns the business name
	GetBusinessName() string
	// SetBusinessName sets the business name
	SetBusinessName(businessName string) UserInterface

	// GetCountry returns the country
	GetCountry() string
	// SetCountry sets the country
	SetCountry(country string) UserInterface

	// GetCreatedAt returns the created at datetime
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the created at datetime as carbon
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the created at datetime
	SetCreatedAt(createdAt string) UserInterface

	// GetEmail returns the email
	GetEmail() string
	// SetEmail sets the email
	SetEmail(email string) UserInterface

	// GetID returns the ID
	GetID() string
	// SetID sets the ID
	SetID(id string) UserInterface

	// GetFirstName returns the first name
	GetFirstName() string
	// SetFirstName sets the first name
	SetFirstName(firstName string) UserInterface

	// GetLastName returns the last name
	GetLastName() string
	// SetLastName sets the last name
	SetLastName(lastName string) UserInterface

	// GetMemo returns the memo
	GetMemo() string
	// SetMemo sets the memo
	SetMemo(memo string) UserInterface

	// GetMeta returns the value of the meta with the given name
	GetMeta(name string) string
	// SetMeta sets the value of the meta with the given name
	SetMeta(name string, value string) error
	// GetMetas returns all metas
	GetMetas() (map[string]string, error)
	// SetMetas sets all metas, overwriting existing ones
	SetMetas(metas map[string]string) error
	// UpsertMetas merges the given metas with the existing ones
	UpsertMetas(metas map[string]string) error

	// GetMiddleNames returns the middle names
	GetMiddleNames() string
	// SetMiddleNames sets the middle names
	SetMiddleNames(middleNames string) UserInterface

	// GetPassword returns the password hash
	GetPassword() string
	// PasswordCompare compares the given password with the stored hash
	PasswordCompare(password string) bool
	// SetPassword sets the password hash
	SetPassword(password string) UserInterface
	// SetPasswordAndHash hashes and sets the given plain text password
	SetPasswordAndHash(password string) error

	// GetPhone returns the phone
	GetPhone() string
	// SetPhone sets the phone
	SetPhone(phone string) UserInterface

	// GetProfileImageUrl returns the profile image URL
	GetProfileImageUrl() string
	// ProfileImageOrDefaultUrl returns the profile image URL or the default URL
	ProfileImageOrDefaultUrl() string
	// SetProfileImageUrl sets the profile image URL
	SetProfileImageUrl(profileImageUrl string) UserInterface

	// GetRole returns the role
	GetRole() string
	// SetRole sets the role
	SetRole(role string) UserInterface

	// GetSoftDeletedAt returns the soft deleted at datetime
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deleted at datetime as carbon
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deleted at datetime
	SetSoftDeletedAt(deletedAt string) UserInterface

	// GetTimezone returns the timezone
	GetTimezone() string
	// SetTimezone sets the timezone
	SetTimezone(timezone string) UserInterface

	// GetStatus returns the status
	GetStatus() string
	// SetStatus sets the status
	SetStatus(status string) UserInterface

	// GetUpdatedAt returns the updated at datetime
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the updated at datetime as carbon
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the updated at datetime
	SetUpdatedAt(updatedAt string) UserInterface
}

UserInterface defines the interface for a user

func NewUser

func NewUser() UserInterface

func NewUserFromExistingData

func NewUserFromExistingData(data map[string]string) UserInterface

type UserQueryInterface

type UserQueryInterface interface {
	// Validate validates the query
	Validate() error

	// Columns returns the columns to return from the database
	Columns() []string

	// SetColumns sets the columns to return from the database
	SetColumns(columns []string) UserQueryInterface

	// HasCountOnly returns true if the query is for counting only
	HasCountOnly() bool

	// IsCountOnly returns true if the query is for counting only
	IsCountOnly() bool

	// SetCountOnly sets the query to count only
	SetCountOnly(countOnly bool) UserQueryInterface

	// HasCreatedAtGte returns true if the query has a created at greater than or equal to
	HasCreatedAtGte() bool

	// CreatedAtGte returns the created at greater than or equal to
	CreatedAtGte() string

	// SetCreatedAtGte sets the created at greater than or equal to
	SetCreatedAtGte(createdAtGte string) UserQueryInterface

	// HasCreatedAtLte returns true if the query has a created at less than or equal to
	HasCreatedAtLte() bool

	// CreatedAtLte returns the created at less than or equal to
	CreatedAtLte() string

	// SetCreatedAtLte sets the created at less than or equal to
	SetCreatedAtLte(createdAtLte string) UserQueryInterface

	// HasEmail returns true if the query has an email
	HasEmail() bool

	// Email returns the email
	Email() string

	// SetEmail sets the email
	SetEmail(email string) UserQueryInterface

	// HasEmailLike returns true if the query has an email like
	HasEmailLike() bool

	// EmailLike returns the email like
	EmailLike() string

	// SetEmailLike sets the email like
	SetEmailLike(emailLike string) UserQueryInterface

	// HasFirstName returns true if the query has a first name
	HasFirstName() bool

	// FirstName returns the first name
	FirstName() string

	// SetFirstName sets the first name
	SetFirstName(firstName string) UserQueryInterface

	// HasFirstNameLike returns true if the query has a first name like
	HasFirstNameLike() bool

	// FirstNameLike returns the first name like
	FirstNameLike() string

	// SetFirstNameLike sets the first name like
	SetFirstNameLike(firstNameLike string) UserQueryInterface

	// HasLastName returns true if the query has a last name
	HasLastName() bool

	// LastName returns the last name
	LastName() string

	// SetLastName sets the last name
	SetLastName(lastName string) UserQueryInterface

	// HasLastNameLike returns true if the query has a last name like
	HasLastNameLike() bool

	// LastNameLike returns the last name like
	LastNameLike() string

	// SetLastNameLike sets the last name like
	SetLastNameLike(lastNameLike string) UserQueryInterface

	// HasID returns true if the query has an ID
	HasID() bool

	// GetID returns the ID
	GetID() string

	// SetID sets the ID
	SetID(id string) UserQueryInterface

	// HasIDIn returns true if the query has an ID in
	HasIDIn() bool

	// IDIn returns the ID in
	IDIn() []string

	// SetIDIn sets the ID in
	SetIDIn(idIn []string) UserQueryInterface

	// HasMetaLike returns true if the query has a meta like
	HasMetaLike() bool

	// MetaLike returns the meta like
	MetaLike() string

	// SetMetaLike sets the meta like
	SetMetaLike(metaLike string) UserQueryInterface

	// HasLimit returns true if the query has a limit
	HasLimit() bool

	// Limit returns the limit
	Limit() int

	// SetLimit sets the limit
	SetLimit(limit int) UserQueryInterface

	// HasOffset returns true if the query has an offset
	HasOffset() bool

	// Offset returns the offset
	Offset() int

	// SetOffset sets the offset
	SetOffset(offset int) UserQueryInterface

	// HasOrderBy returns true if the query has an order by
	HasOrderBy() bool

	// OrderBy returns the order by
	OrderBy() string

	// SetOrderBy sets the order by
	SetOrderBy(orderBy string) UserQueryInterface

	// HasSortDirection returns true if the query has a sort direction
	HasSortDirection() bool

	// SortDirection returns the sort direction
	SortDirection() string

	// SetSortDirection sets the sort direction
	SetSortDirection(sortDirection string) UserQueryInterface

	// HasSoftDeletedIncluded returns true if the query has soft deleted included
	HasSoftDeletedIncluded() bool

	// SoftDeletedIncluded returns the soft deleted included
	SoftDeletedIncluded() bool

	// SetSoftDeletedIncluded sets the soft deleted included
	SetSoftDeletedIncluded(softDeletedIncluded bool) UserQueryInterface

	// HasStatus returns true if the query has a status
	HasStatus() bool

	// Status returns the status
	Status() string

	// SetStatus sets the status
	SetStatus(status string) UserQueryInterface

	// HasStatusIn returns true if the query has a status in
	HasStatusIn() bool

	// StatusIn returns the status in
	StatusIn() []string

	// SetStatusIn sets the status in
	SetStatusIn(statusIn []string) UserQueryInterface
	// contains filtered or unexported methods
}

func NewUserQuery

func NewUserQuery() UserQueryInterface

type UserRoleInterface added in v1.20.0

type UserRoleInterface interface {

	// Data returns all fields as a map
	Data() map[string]string
	// DataChanged returns the changed fields as a map
	DataChanged() map[string]string
	// MarkAsNotDirty marks all fields as not changed
	MarkAsNotDirty()
	// ToMap returns a DB-ready map of the user role
	ToMap() map[string]any

	// IsSoftDeleted returns true if the user role is soft deleted
	IsSoftDeleted() bool

	// GetCreatedAt returns the created at datetime
	GetCreatedAt() string
	// GetCreatedAtCarbon returns the created at datetime as carbon
	GetCreatedAtCarbon() *carbon.Carbon
	// SetCreatedAt sets the created at datetime
	SetCreatedAt(createdAt string) UserRoleInterface

	// GetID returns the ID
	GetID() string
	// SetID sets the ID
	SetID(id string) UserRoleInterface

	// GetUserID returns the user ID
	GetUserID() string
	// SetUserID sets the user ID
	SetUserID(userID string) UserRoleInterface

	// GetRoleID returns the role ID
	GetRoleID() string
	// SetRoleID sets the role ID
	SetRoleID(roleID string) UserRoleInterface

	// GetSoftDeletedAt returns the soft deleted at datetime
	GetSoftDeletedAt() string
	// GetSoftDeletedAtCarbon returns the soft deleted at datetime as carbon
	GetSoftDeletedAtCarbon() *carbon.Carbon
	// SetSoftDeletedAt sets the soft deleted at datetime
	SetSoftDeletedAt(softDeletedAt string) UserRoleInterface

	// GetUpdatedAt returns the updated at datetime
	GetUpdatedAt() string
	// GetUpdatedAtCarbon returns the updated at datetime as carbon
	GetUpdatedAtCarbon() *carbon.Carbon
	// SetUpdatedAt sets the updated at datetime
	SetUpdatedAt(updatedAt string) UserRoleInterface
}

UserRoleInterface defines the interface for a user role assignment

func NewUserRole added in v1.20.0

func NewUserRole() UserRoleInterface

func NewUserRoleFromExistingData added in v1.20.0

func NewUserRoleFromExistingData(data map[string]string) UserRoleInterface

type UserRoleQueryInterface added in v1.20.0

type UserRoleQueryInterface interface {
	// Validate validates the query
	Validate() error

	// Columns returns the columns to return from the database
	Columns() []string
	// SetColumns sets the columns to return from the database
	SetColumns(columns []string) UserRoleQueryInterface

	// HasCountOnly returns true if the query is for counting only
	HasCountOnly() bool
	// IsCountOnly returns true if the query is for counting only
	IsCountOnly() bool
	// SetCountOnly sets the query to count only
	SetCountOnly(countOnly bool) UserRoleQueryInterface

	// HasID returns true if the query has an ID
	HasID() bool
	// GetID returns the ID
	GetID() string
	// SetID sets the ID
	SetID(id string) UserRoleQueryInterface

	// HasIDIn returns true if the query has an ID in
	HasIDIn() bool
	// IDIn returns the ID in
	IDIn() []string
	// SetIDIn sets the ID in
	SetIDIn(idIn []string) UserRoleQueryInterface

	// HasUserID returns true if the query has a user ID
	HasUserID() bool
	// UserID returns the user ID
	UserID() string
	// SetUserID sets the user ID
	SetUserID(userID string) UserRoleQueryInterface

	// HasUserIDIn returns true if the query has a user ID in
	HasUserIDIn() bool
	// UserIDIn returns the user ID in
	UserIDIn() []string
	// SetUserIDIn sets the user ID in
	SetUserIDIn(userIDIn []string) UserRoleQueryInterface

	// HasRoleID returns true if the query has a role ID
	HasRoleID() bool
	// RoleID returns the role ID
	RoleID() string
	// SetRoleID sets the role ID
	SetRoleID(roleID string) UserRoleQueryInterface

	// HasRoleIDIn returns true if the query has a role ID in
	HasRoleIDIn() bool
	// RoleIDIn returns the role ID in
	RoleIDIn() []string
	// SetRoleIDIn sets the role ID in
	SetRoleIDIn(roleIDIn []string) UserRoleQueryInterface

	// HasLimit returns true if the query has a limit
	HasLimit() bool
	// Limit returns the limit
	Limit() int
	// SetLimit sets the limit
	SetLimit(limit int) UserRoleQueryInterface

	// HasOffset returns true if the query has an offset
	HasOffset() bool
	// Offset returns the offset
	Offset() int
	// SetOffset sets the offset
	SetOffset(offset int) UserRoleQueryInterface

	// HasOrderBy returns true if the query has an order by
	HasOrderBy() bool
	// OrderBy returns the order by
	OrderBy() string
	// SetOrderBy sets the order by
	SetOrderBy(orderBy string) UserRoleQueryInterface

	// HasSortDirection returns true if the query has a sort direction
	HasSortDirection() bool
	// SortDirection returns the sort direction
	SortDirection() string
	// SetSortDirection sets the sort direction
	SetSortDirection(sortDirection string) UserRoleQueryInterface

	// HasSoftDeletedIncluded returns true if the query has soft deleted included
	HasSoftDeletedIncluded() bool
	// SoftDeletedIncluded returns the soft deleted included
	SoftDeletedIncluded() bool
	// SetSoftDeletedIncluded sets the soft deleted included
	SetSoftDeletedIncluded(softDeletedIncluded bool) UserRoleQueryInterface
	// contains filtered or unexported methods
}

UserRoleQueryInterface defines the interface for user role queries

func NewUserRoleQuery added in v1.20.0

func NewUserRoleQuery() UserRoleQueryInterface

Directories

Path Synopsis
examples
basic command
groups command
roles command

Jump to

Keyboard shortcuts

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