model

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableUserConstraintPrimaryKey          = "charon.user_id_pkey"
	TableUserConstraintUsernameUnique      = "charon.user_username_key"
	TableUserConstraintCreatedByForeignKey = "charon.user_created_by_fkey"
	TableUserConstraintUpdatedByForeignKey = "charon.user_updated_by_fkey"
)
View Source
const (
	TableUser                        = "charon.user"
	TableUserColumnConfirmationToken = "confirmation_token"
	TableUserColumnCreatedAt         = "created_at"
	TableUserColumnCreatedBy         = "created_by"
	TableUserColumnFirstName         = "first_name"
	TableUserColumnID                = "id"
	TableUserColumnIsActive          = "is_active"
	TableUserColumnIsConfirmed       = "is_confirmed"
	TableUserColumnIsStaff           = "is_staff"
	TableUserColumnIsSuperuser       = "is_superuser"
	TableUserColumnLastLoginAt       = "last_login_at"
	TableUserColumnLastName          = "last_name"
	TableUserColumnPassword          = "password"
	TableUserColumnUpdatedAt         = "updated_at"
	TableUserColumnUpdatedBy         = "updated_by"
	TableUserColumnUsername          = "username"
)
View Source
const (
	TableGroupConstraintNameUnique          = "charon.group_name_key"
	TableGroupConstraintPrimaryKey          = "charon.group_id_pkey"
	TableGroupConstraintCreatedByForeignKey = "charon.group_created_by_fkey"
	TableGroupConstraintUpdatedByForeignKey = "charon.group_updated_by_fkey"
)
View Source
const (
	TableGroup                  = "charon.group"
	TableGroupColumnCreatedAt   = "created_at"
	TableGroupColumnCreatedBy   = "created_by"
	TableGroupColumnDescription = "description"
	TableGroupColumnID          = "id"
	TableGroupColumnName        = "name"
	TableGroupColumnUpdatedAt   = "updated_at"
	TableGroupColumnUpdatedBy   = "updated_by"
)
View Source
const (
	TablePermissionConstraintSubsystemModuleActionUnique = "charon.permission_subsystem_module_action_key"
	TablePermissionConstraintPrimaryKey                  = "charon.permission_id_pkey"
)
View Source
const (
	TablePermission                = "charon.permission"
	TablePermissionColumnAction    = "action"
	TablePermissionColumnCreatedAt = "created_at"
	TablePermissionColumnID        = "id"
	TablePermissionColumnModule    = "module"
	TablePermissionColumnSubsystem = "subsystem"
	TablePermissionColumnUpdatedAt = "updated_at"
)
View Source
const (
	TableUserGroupsConstraintUserIDForeignKey    = "charon.user_groups_user_id_fkey"
	TableUserGroupsConstraintGroupIDForeignKey   = "charon.user_groups_group_id_fkey"
	TableUserGroupsConstraintUserIDGroupIDUnique = "charon.user_groups_user_id_group_id_key"
	TableUserGroupsConstraintCreatedByForeignKey = "charon.user_groups_created_by_fkey"
	TableUserGroupsConstraintUpdatedByForeignKey = "charon.user_groups_updated_by_fkey"
)
View Source
const (
	TableUserGroups                = "charon.user_groups"
	TableUserGroupsColumnCreatedAt = "created_at"
	TableUserGroupsColumnCreatedBy = "created_by"
	TableUserGroupsColumnGroupID   = "group_id"
	TableUserGroupsColumnUpdatedAt = "updated_at"
	TableUserGroupsColumnUpdatedBy = "updated_by"
	TableUserGroupsColumnUserID    = "user_id"
)
View Source
const (
	TableGroupPermissionsConstraintGroupIDForeignKey                                                = "charon.group_permissions_group_id_fkey"
	TableGroupPermissionsConstraintPermissionSubsystemPermissionModulePermissionActionForeignKey    = "charon.group_permissions_subsystem_module_action_fkey"
	TableGroupPermissionsConstraintGroupIDPermissionSubsystemPermissionModulePermissionActionUnique = "charon.group_permissions_group_id_subsystem_module_action_key"
	TableGroupPermissionsConstraintCreatedByForeignKey                                              = "charon.group_permissions_created_by_fkey"
	TableGroupPermissionsConstraintUpdatedByForeignKey                                              = "charon.group_permissions_updated_by_fkey"
)
View Source
const (
	TableGroupPermissions                          = "charon.group_permissions"
	TableGroupPermissionsColumnCreatedAt           = "created_at"
	TableGroupPermissionsColumnCreatedBy           = "created_by"
	TableGroupPermissionsColumnGroupID             = "group_id"
	TableGroupPermissionsColumnPermissionAction    = "permission_action"
	TableGroupPermissionsColumnPermissionModule    = "permission_module"
	TableGroupPermissionsColumnPermissionSubsystem = "permission_subsystem"
	TableGroupPermissionsColumnUpdatedAt           = "updated_at"
	TableGroupPermissionsColumnUpdatedBy           = "updated_by"
)
View Source
const (
	TableUserPermissionsConstraintUserIDForeignKey                                                = "charon.user_permissions_user_id_fkey"
	TableUserPermissionsConstraintPermissionSubsystemPermissionModulePermissionActionForeignKey   = "charon.user_permissions_subsystem_module_action_fkey"
	TableUserPermissionsConstraintUserIDPermissionSubsystemPermissionModulePermissionActionUnique = "charon.user_permissions_user_id_subsystem_module_action_key"
	TableUserPermissionsConstraintCreatedByForeignKey                                             = "charon.user_permissions_created_by_fkey"
	TableUserPermissionsConstraintUpdatedByForeignKey                                             = "charon.user_permissions_updated_by_fkey"
)
View Source
const (
	TableUserPermissions                          = "charon.user_permissions"
	TableUserPermissionsColumnCreatedAt           = "created_at"
	TableUserPermissionsColumnCreatedBy           = "created_by"
	TableUserPermissionsColumnPermissionAction    = "permission_action"
	TableUserPermissionsColumnPermissionModule    = "permission_module"
	TableUserPermissionsColumnPermissionSubsystem = "permission_subsystem"
	TableUserPermissionsColumnUpdatedAt           = "updated_at"
	TableUserPermissionsColumnUpdatedBy           = "updated_by"
	TableUserPermissionsColumnUserID              = "user_id"
)
View Source
const (
	TableRefreshTokenConstraintTokenUnique         = "charon.refresh_token_token_key"
	TableRefreshTokenConstraintUserIDForeignKey    = "charon.refresh_token_user_id_fkey"
	TableRefreshTokenConstraintCreatedByForeignKey = "charon.refresh_token_created_by_fkey"
	TableRefreshTokenConstraintUpdatedByForeignKey = "charon.refresh_token_updated_by_fkey"
)
View Source
const (
	TableRefreshToken                 = "charon.refresh_token"
	TableRefreshTokenColumnCreatedAt  = "created_at"
	TableRefreshTokenColumnCreatedBy  = "created_by"
	TableRefreshTokenColumnExpireAt   = "expire_at"
	TableRefreshTokenColumnLastUsedAt = "last_used_at"
	TableRefreshTokenColumnNotes      = "notes"
	TableRefreshTokenColumnRevoked    = "revoked"
	TableRefreshTokenColumnToken      = "token"
	TableRefreshTokenColumnUpdatedAt  = "updated_at"
	TableRefreshTokenColumnUpdatedBy  = "updated_by"
	TableRefreshTokenColumnUserID     = "user_id"
)
View Source
const (
	JoinInner = iota
	JoinLeft
	JoinRight
	JoinCross
	JoinDoNot
)
View Source
const SQL = `` /* 5133-byte string literal not displayed */
View Source
const (
	// UserConfirmationTokenUsed ...
	UserConfirmationTokenUsed = "!"
)

Variables

View Source
var (
	ErrEmptySliceOfPermissions = errors.New("empty slice, permissions cannot be registered")
	ErrEmptySubsystem          = errors.New("subsystem name is empty string, permissions cannot be registered")
	ErrorInconsistentSubsystem = errors.New("provided permissions do not belong to one subsystem, permissions cannot be registered")
)
View Source
var (
	// Space is a shorthand composition option that holds space.
	Space = &CompositionOpts{
		Joint: " ",
	}
	// And is a shorthand composition option that holds AND operator.
	And = &CompositionOpts{
		Joint: " AND ",
	}
	// Or is a shorthand composition option that holds OR operator.
	Or = &CompositionOpts{
		Joint: " OR ",
	}
	// Comma is a shorthand composition option that holds comma.
	Comma = &CompositionOpts{
		Joint: ", ",
	}
)
View Source
var (
	// ExternalPassword is a password that is set when external source of authentication is provided (e.g. LDAP).
	ExternalPassword = []byte("!")
)
View Source
var RetryTransaction = errors.New("retry transaction")

RetryTransaction can be returned by user defined function when a transaction is rolled back and logic repeated.

Functions

func ErrorConstraint added in v0.9.0

func ErrorConstraint(err error) string

ErrorConstraint returns the error constraint of err if it was produced by the pq library. Otherwise, it returns empty string.

func GroupCriteriaWhereClause added in v0.9.7

func GroupCriteriaWhereClause(comp *Composer, c *GroupCriteria, id int) error

func GroupPermissionsCriteriaWhereClause added in v0.9.7

func GroupPermissionsCriteriaWhereClause(comp *Composer, c *GroupPermissionsCriteria, id int) error

func PermissionCriteriaWhereClause added in v0.9.7

func PermissionCriteriaWhereClause(comp *Composer, c *PermissionCriteria, id int) error

func QueryFloat64WhereClause added in v0.9.0

func QueryFloat64WhereClause(i *qtypes.Float64, id int, sel string, com *Composer, opt *CompositionOpts) (err error)

func QueryInt64WhereClause added in v0.9.0

func QueryInt64WhereClause(i *qtypes.Int64, id int, sel string, com *Composer, opt *CompositionOpts) (err error)

func QueryStringWhereClause added in v0.9.0

func QueryStringWhereClause(i *qtypes.String, id int, sel string, com *Composer, opt *CompositionOpts) (err error)

func QueryTimestampWhereClause added in v0.9.0

func QueryTimestampWhereClause(i *qtypes.Timestamp, id int, sel string, com *Composer, opt *CompositionOpts) (err error)

func RefreshTokenCriteriaWhereClause added in v0.18.0

func RefreshTokenCriteriaWhereClause(comp *Composer, c *RefreshTokenCriteria, id int) error

func RunInTransaction added in v0.18.0

func RunInTransaction(ctx context.Context, db *sql.DB, f func(tx *sql.Tx) error, attempts int) (err error)

func UserCriteriaWhereClause added in v0.9.7

func UserCriteriaWhereClause(comp *Composer, c *UserCriteria, id int) error

func UserGroupsCriteriaWhereClause added in v0.9.7

func UserGroupsCriteriaWhereClause(comp *Composer, c *UserGroupsCriteria, id int) error

func UserPermissionsCriteriaWhereClause added in v0.9.7

func UserPermissionsCriteriaWhereClause(comp *Composer, c *UserPermissionsCriteria, id int) error

Types

type Composer added in v0.9.0

type Composer struct {
	Dirty bool
	// contains filtered or unexported fields
}

Composer holds buffer, arguments and placeholders count. In combination with external buffet can be also used to also generate sub-queries. To do that simply write buffer to the parent buffer, composer will hold all arguments and remember number of last placeholder.

func NewComposer added in v0.9.0

func NewComposer(size int64) *Composer

NewComposer allocates new Composer with inner slice of arguments of given size.

func (*Composer) Add added in v0.9.0

func (c *Composer) Add(arg interface{})

Add appends list with new element.

func (*Composer) Args added in v0.9.0

func (c *Composer) Args() []interface{}

Args returns all arguments stored as a slice.

func (*Composer) Len added in v0.9.0

func (c *Composer) Len() int

Len returns number of arguments.

func (*Composer) Read added in v0.9.0

func (c *Composer) Read(b []byte) (int, error)

Read implements io Reader interface.

func (*Composer) ResetBuf added in v0.9.0

func (c *Composer) ResetBuf()

ResetBuf resets internal buffer.

func (*Composer) String added in v0.9.0

func (c *Composer) String() string

String implements fmt Stringer interface.

func (*Composer) Write added in v0.9.0

func (c *Composer) Write(b []byte) (int, error)

Write implements io Writer interface.

func (*Composer) WriteAlias added in v0.9.7

func (c *Composer) WriteAlias(i int) error

func (*Composer) WritePlaceholder added in v0.9.0

func (c *Composer) WritePlaceholder() error

WritePlaceholder writes appropriate placeholder to the query buffer based on current state of the composer.

func (*Composer) WriteString added in v0.9.0

func (c *Composer) WriteString(s string) (int, error)

WriteString appends the contents of s to the query buffer, growing the buffer as needed. The return value n is the length of s; err is always nil. If the buffer becomes too large, WriteString will panic with bytes ErrTooLarge.

type CompositionOpts added in v0.9.0

type CompositionOpts struct {
	Joint                           string
	PlaceholderFuncs, SelectorFuncs []string
	PlaceholderCast, SelectorCast   string
	IsJSON                          bool
	IsDynamic                       bool
}

CompositionOpts is a container for modification that can be applied.

type CompositionWriter added in v0.9.0

type CompositionWriter interface {
	// WriteComposition is a function that allow custom struct type to be used as a part of criteria.
	// It gives possibility to write custom query based on object that implements this interface.
	WriteComposition(string, *Composer, *CompositionOpts) error
}

CompositionWriter is a simple wrapper for WriteComposition function.

type GroupCountExpr added in v0.9.7

type GroupCountExpr struct {
	Where        *GroupCriteria
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type GroupCriteria

type GroupCriteria struct {
	CreatedAt   *qtypes.Timestamp
	CreatedBy   *qtypes.Int64
	Description *qtypes.String
	ID          *qtypes.Int64
	Name        *qtypes.String
	UpdatedAt   *qtypes.Timestamp
	UpdatedBy   *qtypes.Int64
	// contains filtered or unexported fields
}

func GroupAnd added in v0.18.0

func GroupAnd(operands ...*GroupCriteria) *GroupCriteria

func GroupOperand added in v0.18.0

func GroupOperand(operator string, operands ...*GroupCriteria) *GroupCriteria

func GroupOr added in v0.18.0

func GroupOr(operands ...*GroupCriteria) *GroupCriteria

type GroupEntity

type GroupEntity struct {
	// CreatedAt ...
	CreatedAt time.Time
	// CreatedBy ...
	CreatedBy ntypes.Int64
	// Description ...
	Description ntypes.String
	// ID ...
	ID int64
	// Name ...
	Name string
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// UpdatedBy ...
	UpdatedBy ntypes.Int64
	// Author ...
	Author *UserEntity
	// Modifier ...
	Modifier *UserEntity
	// Permissions ...
	Permissions []*PermissionEntity
	// Users ...
	Users []*UserEntity
}

GroupEntity ...

func ScanGroupRows

func ScanGroupRows(rows Rows) (entities []*GroupEntity, err error)

ScanGroupRows helps to scan rows straight to the slice of entities.

func (*GroupEntity) Prop

func (e *GroupEntity) Prop(cn string) (interface{}, bool)

func (*GroupEntity) Props

func (e *GroupEntity) Props(cns ...string) ([]interface{}, error)

type GroupFindExpr added in v0.9.7

type GroupFindExpr struct {
	Where         *GroupCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
	JoinAuthor    *UserJoin
	JoinModifier  *UserJoin
}

type GroupIterator

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

GroupIterator is not thread safe.

func (*GroupIterator) Close

func (i *GroupIterator) Close() error

func (*GroupIterator) Columns

func (i *GroupIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*GroupIterator) Ent

func (i *GroupIterator) Ent() (interface{}, error)

Ent is wrapper around Group method that makes iterator more generic.

func (*GroupIterator) Err

func (i *GroupIterator) Err() error

func (*GroupIterator) Group

func (i *GroupIterator) Group() (*GroupEntity, error)

func (*GroupIterator) Next

func (i *GroupIterator) Next() bool

type GroupJoin added in v0.9.7

type GroupJoin struct {
	On, Where    *GroupCriteria
	Fetch        bool
	Kind         JoinType
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type GroupPatch

type GroupPatch struct {
	CreatedAt   pq.NullTime
	CreatedBy   ntypes.Int64
	Description ntypes.String
	Name        ntypes.String
	UpdatedAt   pq.NullTime
	UpdatedBy   ntypes.Int64
}

type GroupPermissionsCountExpr added in v0.9.7

type GroupPermissionsCountExpr struct {
	Where        *GroupPermissionsCriteria
	JoinGroup    *GroupJoin
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type GroupPermissionsCriteria

type GroupPermissionsCriteria struct {
	CreatedAt           *qtypes.Timestamp
	CreatedBy           *qtypes.Int64
	GroupID             *qtypes.Int64
	PermissionAction    *qtypes.String
	PermissionModule    *qtypes.String
	PermissionSubsystem *qtypes.String
	UpdatedAt           *qtypes.Timestamp
	UpdatedBy           *qtypes.Int64
	// contains filtered or unexported fields
}

func GroupPermissionsAnd added in v0.18.0

func GroupPermissionsAnd(operands ...*GroupPermissionsCriteria) *GroupPermissionsCriteria

func GroupPermissionsOperand added in v0.18.0

func GroupPermissionsOperand(operator string, operands ...*GroupPermissionsCriteria) *GroupPermissionsCriteria

func GroupPermissionsOr added in v0.18.0

func GroupPermissionsOr(operands ...*GroupPermissionsCriteria) *GroupPermissionsCriteria

type GroupPermissionsEntity

type GroupPermissionsEntity struct {
	// CreatedAt ...
	CreatedAt time.Time
	// CreatedBy ...
	CreatedBy ntypes.Int64
	// GroupID ...
	GroupID int64
	// PermissionAction ...
	PermissionAction string
	// PermissionModule ...
	PermissionModule string
	// PermissionSubsystem ...
	PermissionSubsystem string
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// UpdatedBy ...
	UpdatedBy ntypes.Int64
	// Group ...
	Group *GroupEntity
	// Author ...
	Author *UserEntity
	// Modifier ...
	Modifier *UserEntity
}

GroupPermissionsEntity ...

func ScanGroupPermissionsRows

func ScanGroupPermissionsRows(rows Rows) (entities []*GroupPermissionsEntity, err error)

ScanGroupPermissionsRows helps to scan rows straight to the slice of entities.

func (*GroupPermissionsEntity) Prop

func (e *GroupPermissionsEntity) Prop(cn string) (interface{}, bool)

func (*GroupPermissionsEntity) Props

func (e *GroupPermissionsEntity) Props(cns ...string) ([]interface{}, error)

type GroupPermissionsFindExpr added in v0.9.7

type GroupPermissionsFindExpr struct {
	Where         *GroupPermissionsCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
	JoinGroup     *GroupJoin
	JoinAuthor    *UserJoin
	JoinModifier  *UserJoin
}

type GroupPermissionsIterator

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

GroupPermissionsIterator is not thread safe.

func (*GroupPermissionsIterator) Close

func (i *GroupPermissionsIterator) Close() error

func (*GroupPermissionsIterator) Columns

func (i *GroupPermissionsIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*GroupPermissionsIterator) Ent

func (i *GroupPermissionsIterator) Ent() (interface{}, error)

Ent is wrapper around GroupPermissions method that makes iterator more generic.

func (*GroupPermissionsIterator) Err

func (*GroupPermissionsIterator) GroupPermissions

func (i *GroupPermissionsIterator) GroupPermissions() (*GroupPermissionsEntity, error)

func (*GroupPermissionsIterator) Next

func (i *GroupPermissionsIterator) Next() bool

type GroupPermissionsJoin added in v0.9.7

type GroupPermissionsJoin struct {
	On, Where    *GroupPermissionsCriteria
	Fetch        bool
	Kind         JoinType
	JoinGroup    *GroupJoin
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type GroupPermissionsPatch

type GroupPermissionsPatch struct {
	CreatedAt           pq.NullTime
	CreatedBy           ntypes.Int64
	GroupID             ntypes.Int64
	PermissionAction    ntypes.String
	PermissionModule    ntypes.String
	PermissionSubsystem ntypes.String
	UpdatedAt           pq.NullTime
	UpdatedBy           ntypes.Int64
}

type GroupPermissionsProvider

type GroupPermissionsProvider interface {
	Insert(context.Context, *GroupPermissionsEntity) (*GroupPermissionsEntity, error)
}

GroupPermissionsProvider ...

func NewGroupPermissionsRepository

func NewGroupPermissionsRepository(dbPool *sql.DB) GroupPermissionsProvider

NewGroupPermissionsRepository ...

type GroupPermissionsRepository

type GroupPermissionsRepository struct {
	GroupPermissionsRepositoryBase
}

GroupPermissionsRepository extends GroupPermissionsRepositoryBase

type GroupPermissionsRepositoryBase

type GroupPermissionsRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*GroupPermissionsRepositoryBase) BeginTx added in v0.18.0

func (*GroupPermissionsRepositoryBase) Count

func (*GroupPermissionsRepositoryBase) Find

func (*GroupPermissionsRepositoryBase) FindIter

func (*GroupPermissionsRepositoryBase) FindOneByGroupIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction

func (r *GroupPermissionsRepositoryBase) FindOneByGroupIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction(ctx context.Context, groupPermissionsGroupID int64, groupPermissionsPermissionSubsystem string, groupPermissionsPermissionModule string, groupPermissionsPermissionAction string) (*GroupPermissionsEntity, error)

func (*GroupPermissionsRepositoryBase) FindQuery added in v0.9.0

func (r *GroupPermissionsRepositoryBase) FindQuery(fe *GroupPermissionsFindExpr) (string, []interface{}, error)

func (*GroupPermissionsRepositoryBase) Insert

func (*GroupPermissionsRepositoryBase) InsertQuery added in v0.9.0

func (r *GroupPermissionsRepositoryBase) InsertQuery(e *GroupPermissionsEntity, read bool) (string, []interface{}, error)

func (GroupPermissionsRepositoryBase) RunInTransaction added in v0.18.0

func (r GroupPermissionsRepositoryBase) RunInTransaction(ctx context.Context, fn func(rtx *GroupPermissionsRepositoryBaseTx) error, attempts int) (err error)

func (*GroupPermissionsRepositoryBase) Tx added in v0.18.0

func (*GroupPermissionsRepositoryBase) UpdateOneByGroupIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction

func (r *GroupPermissionsRepositoryBase) UpdateOneByGroupIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction(ctx context.Context, groupPermissionsGroupID int64, groupPermissionsPermissionSubsystem string, groupPermissionsPermissionModule string, groupPermissionsPermissionAction string, p *GroupPermissionsPatch) (*GroupPermissionsEntity, error)

func (*GroupPermissionsRepositoryBase) UpdateOneByGroupIDAndPermissionSubsystemAndPermissionModuleAndPermissionActionQuery added in v0.9.0

func (r *GroupPermissionsRepositoryBase) UpdateOneByGroupIDAndPermissionSubsystemAndPermissionModuleAndPermissionActionQuery(groupPermissionsGroupID int64, groupPermissionsPermissionSubsystem string, groupPermissionsPermissionModule string, groupPermissionsPermissionAction string, p *GroupPermissionsPatch) (string, []interface{}, error)

func (*GroupPermissionsRepositoryBase) Upsert

func (*GroupPermissionsRepositoryBase) UpsertQuery added in v0.9.0

func (r *GroupPermissionsRepositoryBase) UpsertQuery(e *GroupPermissionsEntity, p *GroupPermissionsPatch, inf ...string) (string, []interface{}, error)

type GroupPermissionsRepositoryBaseTx added in v0.18.0

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

func (GroupPermissionsRepositoryBaseTx) Commit added in v0.18.0

func (*GroupPermissionsRepositoryBaseTx) Count added in v0.18.0

func (*GroupPermissionsRepositoryBaseTx) Find added in v0.18.0

func (*GroupPermissionsRepositoryBaseTx) FindIter added in v0.18.0

func (*GroupPermissionsRepositoryBaseTx) Insert added in v0.18.0

func (GroupPermissionsRepositoryBaseTx) Rollback added in v0.18.0

func (*GroupPermissionsRepositoryBaseTx) UpdateOneByGroupIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction added in v0.18.0

func (r *GroupPermissionsRepositoryBaseTx) UpdateOneByGroupIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction(ctx context.Context, groupPermissionsGroupID int64, groupPermissionsPermissionSubsystem string, groupPermissionsPermissionModule string, groupPermissionsPermissionAction string, p *GroupPermissionsPatch) (*GroupPermissionsEntity, error)

func (*GroupPermissionsRepositoryBaseTx) Upsert added in v0.18.0

type GroupProvider

type GroupProvider interface {
	Insert(context.Context, *GroupEntity) (*GroupEntity, error)
	// FindByUserID retrieves all groups for user represented by given id.
	FindByUserID(context.Context, int64) ([]*GroupEntity, error)
	// FindOneByID retrieves group for given id.
	FindOneByID(context.Context, int64) (*GroupEntity, error)
	// find ...
	Find(context.Context, *GroupFindExpr) ([]*GroupEntity, error)
	// Create ...
	Create(ctx context.Context, createdBy int64, name string, description *ntypes.String) (*GroupEntity, error)
	// updateOneByID ...
	UpdateOneByID(context.Context, int64, *GroupPatch) (*GroupEntity, error)
	// DeleteByID ...
	DeleteOneByID(context.Context, int64) (int64, error)
	// IsGranted ...
	IsGranted(context.Context, int64, charon.Permission) (bool, error)
	// SetPermissions ...
	SetPermissions(context.Context, int64, ...charon.Permission) (int64, int64, error)
}

GroupProvider ...

func NewGroupRepository

func NewGroupRepository(dbPool *sql.DB) GroupProvider

NewGroupRepository ...

type GroupRepository

type GroupRepository struct {
	GroupRepositoryBase
	UserGroups UserGroupsRepositoryBase
}

GroupRepository extends GroupRepositoryBase

func (*GroupRepository) Create

func (gr *GroupRepository) Create(ctx context.Context, createdBy int64, name string, description *ntypes.String) (ent *GroupEntity, err error)

Create ...

func (*GroupRepository) FindByUserID

func (gr *GroupRepository) FindByUserID(ctx context.Context, userID int64) ([]*GroupEntity, error)

FindByUserID implements GroupProvider interface.

func (*GroupRepository) IsGranted

func (gr *GroupRepository) IsGranted(ctx context.Context, id int64, p charon.Permission) (bool, error)

IsGranted ...

func (*GroupRepository) SetPermissions

func (gr *GroupRepository) SetPermissions(ctx context.Context, id int64, p ...charon.Permission) (int64, int64, error)

SetPermissions ...

type GroupRepositoryBase

type GroupRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*GroupRepositoryBase) BeginTx added in v0.18.0

func (*GroupRepositoryBase) Count

func (*GroupRepositoryBase) DeleteOneByID

func (r *GroupRepositoryBase) DeleteOneByID(ctx context.Context, pk int64) (int64, error)

func (*GroupRepositoryBase) Find

func (*GroupRepositoryBase) FindIter

func (*GroupRepositoryBase) FindOneByID

func (r *GroupRepositoryBase) FindOneByID(ctx context.Context, pk int64) (*GroupEntity, error)

func (*GroupRepositoryBase) FindOneByIDAndUpdate added in v0.18.0

func (r *GroupRepositoryBase) FindOneByIDAndUpdate(ctx context.Context, pk int64, p *GroupPatch) (before, after *GroupEntity, err error)

func (*GroupRepositoryBase) FindOneByName

func (r *GroupRepositoryBase) FindOneByName(ctx context.Context, groupName string) (*GroupEntity, error)

func (*GroupRepositoryBase) FindQuery added in v0.9.0

func (r *GroupRepositoryBase) FindQuery(fe *GroupFindExpr) (string, []interface{}, error)

func (*GroupRepositoryBase) Insert

func (*GroupRepositoryBase) InsertQuery added in v0.9.0

func (r *GroupRepositoryBase) InsertQuery(e *GroupEntity, read bool) (string, []interface{}, error)

func (GroupRepositoryBase) RunInTransaction added in v0.18.0

func (r GroupRepositoryBase) RunInTransaction(ctx context.Context, fn func(rtx *GroupRepositoryBaseTx) error, attempts int) (err error)

func (*GroupRepositoryBase) Tx added in v0.18.0

func (*GroupRepositoryBase) UpdateOneByID

func (r *GroupRepositoryBase) UpdateOneByID(ctx context.Context, pk int64, p *GroupPatch) (*GroupEntity, error)

func (*GroupRepositoryBase) UpdateOneByIDQuery added in v0.9.0

func (r *GroupRepositoryBase) UpdateOneByIDQuery(pk int64, p *GroupPatch) (string, []interface{}, error)

func (*GroupRepositoryBase) UpdateOneByName

func (r *GroupRepositoryBase) UpdateOneByName(ctx context.Context, groupName string, p *GroupPatch) (*GroupEntity, error)

func (*GroupRepositoryBase) UpdateOneByNameQuery added in v0.9.0

func (r *GroupRepositoryBase) UpdateOneByNameQuery(groupName string, p *GroupPatch) (string, []interface{}, error)

func (*GroupRepositoryBase) Upsert

func (r *GroupRepositoryBase) Upsert(ctx context.Context, e *GroupEntity, p *GroupPatch, inf ...string) (*GroupEntity, error)

func (*GroupRepositoryBase) UpsertQuery added in v0.9.0

func (r *GroupRepositoryBase) UpsertQuery(e *GroupEntity, p *GroupPatch, inf ...string) (string, []interface{}, error)

type GroupRepositoryBaseTx added in v0.18.0

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

func (GroupRepositoryBaseTx) Commit added in v0.18.0

func (r GroupRepositoryBaseTx) Commit() error

func (*GroupRepositoryBaseTx) Count added in v0.18.0

func (*GroupRepositoryBaseTx) DeleteOneByID added in v0.18.0

func (r *GroupRepositoryBaseTx) DeleteOneByID(ctx context.Context, pk int64) (int64, error)

func (*GroupRepositoryBaseTx) Find added in v0.18.0

func (*GroupRepositoryBaseTx) FindIter added in v0.18.0

func (*GroupRepositoryBaseTx) FindOneByID added in v0.18.0

func (r *GroupRepositoryBaseTx) FindOneByID(ctx context.Context, pk int64) (*GroupEntity, error)

func (*GroupRepositoryBaseTx) Insert added in v0.18.0

func (GroupRepositoryBaseTx) Rollback added in v0.18.0

func (r GroupRepositoryBaseTx) Rollback() error

func (*GroupRepositoryBaseTx) UpdateOneByID added in v0.18.0

func (r *GroupRepositoryBaseTx) UpdateOneByID(ctx context.Context, pk int64, p *GroupPatch) (*GroupEntity, error)

func (*GroupRepositoryBaseTx) UpdateOneByName added in v0.18.0

func (r *GroupRepositoryBaseTx) UpdateOneByName(ctx context.Context, groupName string, p *GroupPatch) (*GroupEntity, error)

func (*GroupRepositoryBaseTx) Upsert added in v0.18.0

type JSONArrayFloat64 added in v0.9.0

type JSONArrayFloat64 []float64

JSONArrayFloat64 is a slice of int64s that implements necessary interfaces.

func (*JSONArrayFloat64) Scan added in v0.9.0

func (a *JSONArrayFloat64) Scan(src interface{}) error

Scan satisfy sql.Scanner interface.

func (JSONArrayFloat64) Value added in v0.9.0

func (a JSONArrayFloat64) Value() (driver.Value, error)

Value satisfy driver.Valuer interface.

type JSONArrayInt64 added in v0.9.0

type JSONArrayInt64 []int64

JSONArrayInt64 is a slice of int64s that implements necessary interfaces.

func (*JSONArrayInt64) Scan added in v0.9.0

func (a *JSONArrayInt64) Scan(src interface{}) error

Scan satisfy sql.Scanner interface.

func (JSONArrayInt64) Value added in v0.9.0

func (a JSONArrayInt64) Value() (driver.Value, error)

Value satisfy driver.Valuer interface.

type JSONArrayString added in v0.9.0

type JSONArrayString []string

JSONArrayString is a slice of strings that implements necessary interfaces.

func (*JSONArrayString) Scan added in v0.9.0

func (a *JSONArrayString) Scan(src interface{}) error

Scan satisfy sql.Scanner interface.

func (JSONArrayString) Value added in v0.9.0

func (a JSONArrayString) Value() (driver.Value, error)

Value satisfy driver.Valuer interface.

type JoinType added in v0.9.7

type JoinType int

func (JoinType) Actionable added in v0.18.0

func (jt JoinType) Actionable() bool

Actionable returns true if JoinType is one of the known type except JoinDoNot.

func (JoinType) String added in v0.9.7

func (jt JoinType) String() string

type LogFunc added in v0.10.0

type LogFunc func(err error, ent, fnc, sql string, args ...interface{})

LogFunc represents function that can be passed into repository to log query result.

type NullBoolArray added in v0.9.0

type NullBoolArray struct {
	pq.BoolArray
	Valid bool
}

func (*NullBoolArray) Scan added in v0.9.0

func (n *NullBoolArray) Scan(value interface{}) error

type NullByteaArray added in v0.9.0

type NullByteaArray struct {
	pq.ByteaArray
	Valid bool
}

func (*NullByteaArray) Scan added in v0.9.0

func (n *NullByteaArray) Scan(value interface{}) error

type NullFloat64Array added in v0.9.0

type NullFloat64Array struct {
	pq.Float64Array
	Valid bool
}

func (*NullFloat64Array) Scan added in v0.9.0

func (n *NullFloat64Array) Scan(value interface{}) error

type NullInt64Array added in v0.9.0

type NullInt64Array struct {
	pq.Int64Array
	Valid bool
}

func (*NullInt64Array) Scan added in v0.9.0

func (n *NullInt64Array) Scan(value interface{}) error

type NullStringArray added in v0.9.0

type NullStringArray struct {
	pq.StringArray
	Valid bool
}

func (*NullStringArray) Scan added in v0.9.0

func (n *NullStringArray) Scan(value interface{}) error

type PermissionCountExpr added in v0.9.7

type PermissionCountExpr struct {
	Where *PermissionCriteria
}

type PermissionCriteria

type PermissionCriteria struct {
	Action    *qtypes.String
	CreatedAt *qtypes.Timestamp
	ID        *qtypes.Int64
	Module    *qtypes.String
	Subsystem *qtypes.String
	UpdatedAt *qtypes.Timestamp
	// contains filtered or unexported fields
}

func PermissionAnd added in v0.18.0

func PermissionAnd(operands ...*PermissionCriteria) *PermissionCriteria

func PermissionOperand added in v0.18.0

func PermissionOperand(operator string, operands ...*PermissionCriteria) *PermissionCriteria

func PermissionOr added in v0.18.0

func PermissionOr(operands ...*PermissionCriteria) *PermissionCriteria

type PermissionEntity

type PermissionEntity struct {
	// Action ...
	Action string
	// CreatedAt ...
	CreatedAt time.Time
	// ID ...
	ID int64
	// Module ...
	Module string
	// Subsystem ...
	Subsystem string
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// Users ...
	Users []*UserEntity
	// Groups ...
	Groups []*GroupEntity
}

PermissionEntity ...

func ScanPermissionRows

func ScanPermissionRows(rows Rows) (entities []*PermissionEntity, err error)

ScanPermissionRows helps to scan rows straight to the slice of entities.

func (*PermissionEntity) Permission

func (pe *PermissionEntity) Permission() charon.Permission

Permission returns charon.Permission value that is concatenated using entity properties like subsystem, module and action.

func (*PermissionEntity) Prop

func (e *PermissionEntity) Prop(cn string) (interface{}, bool)

func (*PermissionEntity) Props

func (e *PermissionEntity) Props(cns ...string) ([]interface{}, error)

type PermissionFindExpr added in v0.9.7

type PermissionFindExpr struct {
	Where         *PermissionCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
}

type PermissionIterator

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

PermissionIterator is not thread safe.

func (*PermissionIterator) Close

func (i *PermissionIterator) Close() error

func (*PermissionIterator) Columns

func (i *PermissionIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*PermissionIterator) Ent

func (i *PermissionIterator) Ent() (interface{}, error)

Ent is wrapper around Permission method that makes iterator more generic.

func (*PermissionIterator) Err

func (i *PermissionIterator) Err() error

func (*PermissionIterator) Next

func (i *PermissionIterator) Next() bool

func (*PermissionIterator) Permission

func (i *PermissionIterator) Permission() (*PermissionEntity, error)

type PermissionJoin added in v0.9.7

type PermissionJoin struct {
	On, Where *PermissionCriteria
	Fetch     bool
	Kind      JoinType
}

type PermissionPatch

type PermissionPatch struct {
	Action    ntypes.String
	CreatedAt pq.NullTime
	Module    ntypes.String
	Subsystem ntypes.String
	UpdatedAt pq.NullTime
}

type PermissionProvider

type PermissionProvider interface {
	Find(ctx context.Context, criteria *PermissionFindExpr) ([]*PermissionEntity, error)
	FindOneByID(ctx context.Context, id int64) (entity *PermissionEntity, err error)
	// FindByUserID retrieves all permissions for user represented by given id.
	FindByUserID(ctx context.Context, userID int64) (entities []*PermissionEntity, err error)
	// FindByGroupID retrieves all permissions for group represented by given id.
	FindByGroupID(ctx context.Context, groupID int64) (entities []*PermissionEntity, err error)
	Register(ctx context.Context, permissions charon.Permissions) (created, untouched, removed int64, err error)
	Insert(ctx context.Context, entity *PermissionEntity) (*PermissionEntity, error)
	InsertMissing(ctx context.Context, permissions charon.Permissions) (int64, error)
}

PermissionProvider ...

type PermissionReg

type PermissionReg struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PermissionReg ...

func NewPermissionRegistry

func NewPermissionRegistry(r PermissionProvider) *PermissionReg

NewPermissionRegistry ...

func (*PermissionReg) Exists

func (pr *PermissionReg) Exists(_ context.Context, permission charon.Permission) (ok bool)

Exists ...

func (*PermissionReg) Register

func (pr *PermissionReg) Register(ctx context.Context, permissions charon.Permissions) (created, untouched, removed int64, err error)

Register ...

type PermissionRegistry

type PermissionRegistry interface {
	// Exists returns true if given charon.Permission was already registered.
	Exists(ctx context.Context, permission charon.Permission) (exists bool)
	// Register checks if given collection is valid and
	// calls PermissionProvider to store provided permissions
	// in persistent way.
	Register(ctx context.Context, permissions charon.Permissions) (created, untouched, removed int64, err error)
}

PermissionRegistry is an interface that describes in memory storage that holds information about permissions that was registered by 3rd party services. Should be only used as a proxy for registration process to avoid multiple sql hits.

type PermissionRepository

type PermissionRepository struct {
	PermissionRepositoryBase
	// contains filtered or unexported fields
}

PermissionRepository extends PermissionRepositoryBase

func NewPermissionRepository

func NewPermissionRepository(dbPool *sql.DB) *PermissionRepository

NewPermissionRepository ...

func (*PermissionRepository) FindBy

func (pr *PermissionRepository) FindBy(ctx context.Context, query string, args ...interface{}) ([]*PermissionEntity, error)

FindBy ...

func (*PermissionRepository) FindByGroupID

func (pr *PermissionRepository) FindByGroupID(ctx context.Context, groupID int64) ([]*PermissionEntity, error)

FindByGroupID implements PermissionProvider interface.

func (*PermissionRepository) FindByTag

func (pr *PermissionRepository) FindByTag(ctx context.Context, userID int64) ([]*PermissionEntity, error)

FindByTag ...

func (*PermissionRepository) FindByUserID

func (pr *PermissionRepository) FindByUserID(ctx context.Context, userID int64) ([]*PermissionEntity, error)

FindByUserID implements PermissionProvider interface.

func (*PermissionRepository) InsertMissing added in v0.15.0

func (pr *PermissionRepository) InsertMissing(ctx context.Context, permissions charon.Permissions) (int64, error)

func (*PermissionRepository) Register

func (pr *PermissionRepository) Register(ctx context.Context, permissions charon.Permissions) (created, unt, removed int64, err error)

Register ...

type PermissionRepositoryBase

type PermissionRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*PermissionRepositoryBase) BeginTx added in v0.18.0

func (*PermissionRepositoryBase) Count

func (*PermissionRepositoryBase) DeleteOneByID

func (r *PermissionRepositoryBase) DeleteOneByID(ctx context.Context, pk int64) (int64, error)

func (*PermissionRepositoryBase) Find

func (*PermissionRepositoryBase) FindIter

func (*PermissionRepositoryBase) FindOneByID

func (*PermissionRepositoryBase) FindOneByIDAndUpdate added in v0.18.0

func (r *PermissionRepositoryBase) FindOneByIDAndUpdate(ctx context.Context, pk int64, p *PermissionPatch) (before, after *PermissionEntity, err error)

func (*PermissionRepositoryBase) FindOneBySubsystemAndModuleAndAction

func (r *PermissionRepositoryBase) FindOneBySubsystemAndModuleAndAction(ctx context.Context, permissionSubsystem string, permissionModule string, permissionAction string) (*PermissionEntity, error)

func (*PermissionRepositoryBase) FindQuery added in v0.9.0

func (r *PermissionRepositoryBase) FindQuery(fe *PermissionFindExpr) (string, []interface{}, error)

func (*PermissionRepositoryBase) Insert

func (*PermissionRepositoryBase) InsertQuery added in v0.9.0

func (r *PermissionRepositoryBase) InsertQuery(e *PermissionEntity, read bool) (string, []interface{}, error)

func (PermissionRepositoryBase) RunInTransaction added in v0.18.0

func (r PermissionRepositoryBase) RunInTransaction(ctx context.Context, fn func(rtx *PermissionRepositoryBaseTx) error, attempts int) (err error)

func (*PermissionRepositoryBase) Tx added in v0.18.0

func (*PermissionRepositoryBase) UpdateOneByID

func (*PermissionRepositoryBase) UpdateOneByIDQuery added in v0.9.0

func (r *PermissionRepositoryBase) UpdateOneByIDQuery(pk int64, p *PermissionPatch) (string, []interface{}, error)

func (*PermissionRepositoryBase) UpdateOneBySubsystemAndModuleAndAction

func (r *PermissionRepositoryBase) UpdateOneBySubsystemAndModuleAndAction(ctx context.Context, permissionSubsystem string, permissionModule string, permissionAction string, p *PermissionPatch) (*PermissionEntity, error)

func (*PermissionRepositoryBase) UpdateOneBySubsystemAndModuleAndActionQuery added in v0.9.0

func (r *PermissionRepositoryBase) UpdateOneBySubsystemAndModuleAndActionQuery(permissionSubsystem string, permissionModule string, permissionAction string, p *PermissionPatch) (string, []interface{}, error)

func (*PermissionRepositoryBase) Upsert

func (*PermissionRepositoryBase) UpsertQuery added in v0.9.0

func (r *PermissionRepositoryBase) UpsertQuery(e *PermissionEntity, p *PermissionPatch, inf ...string) (string, []interface{}, error)

type PermissionRepositoryBaseTx added in v0.18.0

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

func (PermissionRepositoryBaseTx) Commit added in v0.18.0

func (r PermissionRepositoryBaseTx) Commit() error

func (*PermissionRepositoryBaseTx) Count added in v0.18.0

func (*PermissionRepositoryBaseTx) DeleteOneByID added in v0.18.0

func (r *PermissionRepositoryBaseTx) DeleteOneByID(ctx context.Context, pk int64) (int64, error)

func (*PermissionRepositoryBaseTx) Find added in v0.18.0

func (*PermissionRepositoryBaseTx) FindIter added in v0.18.0

func (*PermissionRepositoryBaseTx) FindOneByID added in v0.18.0

func (*PermissionRepositoryBaseTx) Insert added in v0.18.0

func (PermissionRepositoryBaseTx) Rollback added in v0.18.0

func (r PermissionRepositoryBaseTx) Rollback() error

func (*PermissionRepositoryBaseTx) UpdateOneByID added in v0.18.0

func (*PermissionRepositoryBaseTx) UpdateOneBySubsystemAndModuleAndAction added in v0.18.0

func (r *PermissionRepositoryBaseTx) UpdateOneBySubsystemAndModuleAndAction(ctx context.Context, permissionSubsystem string, permissionModule string, permissionAction string, p *PermissionPatch) (*PermissionEntity, error)

func (*PermissionRepositoryBaseTx) Upsert added in v0.18.0

type RefreshTokenCountExpr added in v0.18.0

type RefreshTokenCountExpr struct {
	Where        *RefreshTokenCriteria
	JoinUser     *UserJoin
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type RefreshTokenCriteria added in v0.18.0

type RefreshTokenCriteria struct {
	CreatedAt  *qtypes.Timestamp
	CreatedBy  *qtypes.Int64
	ExpireAt   *qtypes.Timestamp
	LastUsedAt *qtypes.Timestamp
	Notes      *qtypes.String
	Revoked    ntypes.Bool
	Token      *qtypes.String
	UpdatedAt  *qtypes.Timestamp
	UpdatedBy  *qtypes.Int64
	UserID     *qtypes.Int64
	// contains filtered or unexported fields
}

func RefreshTokenAnd added in v0.18.0

func RefreshTokenAnd(operands ...*RefreshTokenCriteria) *RefreshTokenCriteria

func RefreshTokenOperand added in v0.18.0

func RefreshTokenOperand(operator string, operands ...*RefreshTokenCriteria) *RefreshTokenCriteria

func RefreshTokenOr added in v0.18.0

func RefreshTokenOr(operands ...*RefreshTokenCriteria) *RefreshTokenCriteria

type RefreshTokenEntity added in v0.18.0

type RefreshTokenEntity struct {
	// CreatedAt ...
	CreatedAt time.Time
	// CreatedBy ...
	CreatedBy ntypes.Int64
	// ExpireAt ...
	ExpireAt pq.NullTime
	// LastUsedAt ...
	LastUsedAt pq.NullTime
	// Notes ...
	Notes ntypes.String
	// Revoked ...
	Revoked bool
	// Token ...
	Token string
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// UpdatedBy ...
	UpdatedBy ntypes.Int64
	// UserID ...
	UserID int64
	// User ...
	User *UserEntity
	// Author ...
	Author *UserEntity
	// Modifier ...
	Modifier *UserEntity
}

RefreshTokenEntity ...

func ScanRefreshTokenRows added in v0.18.0

func ScanRefreshTokenRows(rows Rows) (entities []*RefreshTokenEntity, err error)

ScanRefreshTokenRows helps to scan rows straight to the slice of entities.

func (*RefreshTokenEntity) Prop added in v0.18.0

func (e *RefreshTokenEntity) Prop(cn string) (interface{}, bool)

func (*RefreshTokenEntity) Props added in v0.18.0

func (e *RefreshTokenEntity) Props(cns ...string) ([]interface{}, error)

type RefreshTokenFindExpr added in v0.18.0

type RefreshTokenFindExpr struct {
	Where         *RefreshTokenCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
	JoinUser      *UserJoin
	JoinAuthor    *UserJoin
	JoinModifier  *UserJoin
}

type RefreshTokenIterator added in v0.18.0

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

RefreshTokenIterator is not thread safe.

func (*RefreshTokenIterator) Close added in v0.18.0

func (i *RefreshTokenIterator) Close() error

func (*RefreshTokenIterator) Columns added in v0.18.0

func (i *RefreshTokenIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*RefreshTokenIterator) Ent added in v0.18.0

func (i *RefreshTokenIterator) Ent() (interface{}, error)

Ent is wrapper around RefreshToken method that makes iterator more generic.

func (*RefreshTokenIterator) Err added in v0.18.0

func (i *RefreshTokenIterator) Err() error

func (*RefreshTokenIterator) Next added in v0.18.0

func (i *RefreshTokenIterator) Next() bool

func (*RefreshTokenIterator) RefreshToken added in v0.18.0

func (i *RefreshTokenIterator) RefreshToken() (*RefreshTokenEntity, error)

type RefreshTokenJoin added in v0.18.0

type RefreshTokenJoin struct {
	On, Where    *RefreshTokenCriteria
	Fetch        bool
	Kind         JoinType
	JoinUser     *UserJoin
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type RefreshTokenPatch added in v0.18.0

type RefreshTokenPatch struct {
	CreatedAt  pq.NullTime
	CreatedBy  ntypes.Int64
	ExpireAt   pq.NullTime
	LastUsedAt pq.NullTime
	Notes      ntypes.String
	Revoked    ntypes.Bool
	Token      ntypes.String
	UpdatedAt  pq.NullTime
	UpdatedBy  ntypes.Int64
	UserID     ntypes.Int64
}

type RefreshTokenProvider added in v0.18.0

type RefreshTokenProvider interface {
	// Find ...
	Find(context.Context, *RefreshTokenFindExpr) ([]*RefreshTokenEntity, error)
	// FindOneByToken ...
	FindOneByToken(context.Context, string) (*RefreshTokenEntity, error)
	// Create ...
	Create(context.Context, *RefreshTokenEntity) (*RefreshTokenEntity, error)
	// UpdateOneByToken ...
	UpdateOneByToken(context.Context, string, *RefreshTokenPatch) (*RefreshTokenEntity, error)
	// FindOneByTokenAndUserID .
	FindOneByTokenAndUserID(ctx context.Context, token string, userID int64) (*RefreshTokenEntity, error)
}

RefreshTokenProvider ...

func NewRefreshTokenRepository added in v0.18.0

func NewRefreshTokenRepository(dbPool *sql.DB) RefreshTokenProvider

NewRefreshTokenRepository ...

type RefreshTokenRepository added in v0.18.0

type RefreshTokenRepository struct {
	RefreshTokenRepositoryBase
}

RefreshTokenRepository extends RefreshTokenRepositoryBase

func (*RefreshTokenRepository) Create added in v0.18.0

Create ...

func (*RefreshTokenRepository) FindOneByTokenAndUserID added in v0.18.0

func (rtr *RefreshTokenRepository) FindOneByTokenAndUserID(ctx context.Context, token string, userID int64) (*RefreshTokenEntity, error)

FindOneByTokenAndUserID ...

type RefreshTokenRepositoryBase added in v0.18.0

type RefreshTokenRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*RefreshTokenRepositoryBase) BeginTx added in v0.18.0

func (*RefreshTokenRepositoryBase) Count added in v0.18.0

func (*RefreshTokenRepositoryBase) Find added in v0.18.0

func (*RefreshTokenRepositoryBase) FindIter added in v0.18.0

func (*RefreshTokenRepositoryBase) FindOneByToken added in v0.18.0

func (r *RefreshTokenRepositoryBase) FindOneByToken(ctx context.Context, refreshTokenToken string) (*RefreshTokenEntity, error)

func (*RefreshTokenRepositoryBase) FindQuery added in v0.18.0

func (r *RefreshTokenRepositoryBase) FindQuery(fe *RefreshTokenFindExpr) (string, []interface{}, error)

func (*RefreshTokenRepositoryBase) Insert added in v0.18.0

func (*RefreshTokenRepositoryBase) InsertQuery added in v0.18.0

func (r *RefreshTokenRepositoryBase) InsertQuery(e *RefreshTokenEntity, read bool) (string, []interface{}, error)

func (RefreshTokenRepositoryBase) RunInTransaction added in v0.18.0

func (r RefreshTokenRepositoryBase) RunInTransaction(ctx context.Context, fn func(rtx *RefreshTokenRepositoryBaseTx) error, attempts int) (err error)

func (*RefreshTokenRepositoryBase) Tx added in v0.18.0

func (*RefreshTokenRepositoryBase) UpdateOneByToken added in v0.18.0

func (r *RefreshTokenRepositoryBase) UpdateOneByToken(ctx context.Context, refreshTokenToken string, p *RefreshTokenPatch) (*RefreshTokenEntity, error)

func (*RefreshTokenRepositoryBase) UpdateOneByTokenQuery added in v0.18.0

func (r *RefreshTokenRepositoryBase) UpdateOneByTokenQuery(refreshTokenToken string, p *RefreshTokenPatch) (string, []interface{}, error)

func (*RefreshTokenRepositoryBase) Upsert added in v0.18.0

func (*RefreshTokenRepositoryBase) UpsertQuery added in v0.18.0

func (r *RefreshTokenRepositoryBase) UpsertQuery(e *RefreshTokenEntity, p *RefreshTokenPatch, inf ...string) (string, []interface{}, error)

type RefreshTokenRepositoryBaseTx added in v0.18.0

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

func (RefreshTokenRepositoryBaseTx) Commit added in v0.18.0

func (*RefreshTokenRepositoryBaseTx) Count added in v0.18.0

func (*RefreshTokenRepositoryBaseTx) Find added in v0.18.0

func (*RefreshTokenRepositoryBaseTx) FindIter added in v0.18.0

func (*RefreshTokenRepositoryBaseTx) Insert added in v0.18.0

func (RefreshTokenRepositoryBaseTx) Rollback added in v0.18.0

func (r RefreshTokenRepositoryBaseTx) Rollback() error

func (*RefreshTokenRepositoryBaseTx) UpdateOneByToken added in v0.18.0

func (r *RefreshTokenRepositoryBaseTx) UpdateOneByToken(ctx context.Context, refreshTokenToken string, p *RefreshTokenPatch) (*RefreshTokenEntity, error)

func (*RefreshTokenRepositoryBaseTx) Upsert added in v0.18.0

type RowOrder added in v0.18.0

type RowOrder struct {
	Name       string
	Descending bool
}

type Rows added in v0.10.0

type Rows interface {
	io.Closer
	ColumnTypes() ([]*sql.ColumnType, error)
	Columns() ([]string, error)
	Err() error
	Next() bool
	NextResultSet() bool
	Scan(dst ...interface{}) error
}

Rows ...

type UserCountExpr added in v0.9.7

type UserCountExpr struct {
	Where        *UserCriteria
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type UserCriteria

type UserCriteria struct {
	ConfirmationToken []byte
	CreatedAt         *qtypes.Timestamp
	CreatedBy         *qtypes.Int64
	FirstName         *qtypes.String
	ID                *qtypes.Int64
	IsActive          ntypes.Bool
	IsConfirmed       ntypes.Bool
	IsStaff           ntypes.Bool
	IsSuperuser       ntypes.Bool
	LastLoginAt       *qtypes.Timestamp
	LastName          *qtypes.String
	Password          []byte
	UpdatedAt         *qtypes.Timestamp
	UpdatedBy         *qtypes.Int64
	Username          *qtypes.String
	// contains filtered or unexported fields
}

func UserAnd added in v0.18.0

func UserAnd(operands ...*UserCriteria) *UserCriteria

func UserOperand added in v0.18.0

func UserOperand(operator string, operands ...*UserCriteria) *UserCriteria

func UserOr added in v0.18.0

func UserOr(operands ...*UserCriteria) *UserCriteria

type UserEntity

type UserEntity struct {
	// ConfirmationToken ...
	ConfirmationToken []byte
	// CreatedAt ...
	CreatedAt time.Time
	// CreatedBy ...
	CreatedBy ntypes.Int64
	// FirstName ...
	FirstName string
	// ID ...
	ID int64
	// IsActive ...
	IsActive bool
	// IsConfirmed ...
	IsConfirmed bool
	// IsStaff ...
	IsStaff bool
	// IsSuperuser ...
	IsSuperuser bool
	// LastLoginAt ...
	LastLoginAt pq.NullTime
	// LastName ...
	LastName string
	// Password ...
	Password []byte
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// UpdatedBy ...
	UpdatedBy ntypes.Int64
	// Username ...
	Username string
	// Author ...
	Author *UserEntity
	// Modifier ...
	Modifier *UserEntity
	// Permissions ...
	Permissions []*PermissionEntity
	// Groups ...
	Groups []*GroupEntity
}

UserEntity ...

func ScanUserRows

func ScanUserRows(rows Rows) (entities []*UserEntity, err error)

ScanUserRows helps to scan rows straight to the slice of entities.

func (*UserEntity) Prop

func (e *UserEntity) Prop(cn string) (interface{}, bool)

func (*UserEntity) Props

func (e *UserEntity) Props(cns ...string) ([]interface{}, error)

func (*UserEntity) String

func (ue *UserEntity) String() string

String return concatenated first and last name of the user. Implements fmt Stringer interface.

type UserFindExpr added in v0.9.7

type UserFindExpr struct {
	Where         *UserCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
	JoinAuthor    *UserJoin
	JoinModifier  *UserJoin
}

type UserGroupsCountExpr added in v0.9.7

type UserGroupsCountExpr struct {
	Where        *UserGroupsCriteria
	JoinUser     *UserJoin
	JoinGroup    *GroupJoin
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type UserGroupsCriteria

type UserGroupsCriteria struct {
	CreatedAt *qtypes.Timestamp
	CreatedBy *qtypes.Int64
	GroupID   *qtypes.Int64
	UpdatedAt *qtypes.Timestamp
	UpdatedBy *qtypes.Int64
	UserID    *qtypes.Int64
	// contains filtered or unexported fields
}

func UserGroupsAnd added in v0.18.0

func UserGroupsAnd(operands ...*UserGroupsCriteria) *UserGroupsCriteria

func UserGroupsOperand added in v0.18.0

func UserGroupsOperand(operator string, operands ...*UserGroupsCriteria) *UserGroupsCriteria

func UserGroupsOr added in v0.18.0

func UserGroupsOr(operands ...*UserGroupsCriteria) *UserGroupsCriteria

type UserGroupsEntity

type UserGroupsEntity struct {
	// CreatedAt ...
	CreatedAt time.Time
	// CreatedBy ...
	CreatedBy ntypes.Int64
	// GroupID ...
	GroupID int64
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// UpdatedBy ...
	UpdatedBy ntypes.Int64
	// UserID ...
	UserID int64
	// User ...
	User *UserEntity
	// Group ...
	Group *GroupEntity
	// Author ...
	Author *UserEntity
	// Modifier ...
	Modifier *UserEntity
}

UserGroupsEntity ...

func ScanUserGroupsRows

func ScanUserGroupsRows(rows Rows) (entities []*UserGroupsEntity, err error)

ScanUserGroupsRows helps to scan rows straight to the slice of entities.

func (*UserGroupsEntity) Prop

func (e *UserGroupsEntity) Prop(cn string) (interface{}, bool)

func (*UserGroupsEntity) Props

func (e *UserGroupsEntity) Props(cns ...string) ([]interface{}, error)

type UserGroupsFindExpr added in v0.9.7

type UserGroupsFindExpr struct {
	Where         *UserGroupsCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
	JoinUser      *UserJoin
	JoinGroup     *GroupJoin
	JoinAuthor    *UserJoin
	JoinModifier  *UserJoin
}

type UserGroupsIterator

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

UserGroupsIterator is not thread safe.

func (*UserGroupsIterator) Close

func (i *UserGroupsIterator) Close() error

func (*UserGroupsIterator) Columns

func (i *UserGroupsIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*UserGroupsIterator) Ent

func (i *UserGroupsIterator) Ent() (interface{}, error)

Ent is wrapper around UserGroups method that makes iterator more generic.

func (*UserGroupsIterator) Err

func (i *UserGroupsIterator) Err() error

func (*UserGroupsIterator) Next

func (i *UserGroupsIterator) Next() bool

func (*UserGroupsIterator) UserGroups

func (i *UserGroupsIterator) UserGroups() (*UserGroupsEntity, error)

type UserGroupsJoin added in v0.9.7

type UserGroupsJoin struct {
	On, Where    *UserGroupsCriteria
	Fetch        bool
	Kind         JoinType
	JoinUser     *UserJoin
	JoinGroup    *GroupJoin
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type UserGroupsPatch

type UserGroupsPatch struct {
	CreatedAt pq.NullTime
	CreatedBy ntypes.Int64
	GroupID   ntypes.Int64
	UpdatedAt pq.NullTime
	UpdatedBy ntypes.Int64
	UserID    ntypes.Int64
}

type UserGroupsProvider

type UserGroupsProvider interface {
	Insert(ctx context.Context, ent *UserGroupsEntity) (*UserGroupsEntity, error)
	Exists(ctx context.Context, userID, groupID int64) (bool, error)
	Find(ctx context.Context, expr *UserGroupsFindExpr) ([]*UserGroupsEntity, error)
	Set(ctx context.Context, userID int64, groupIDs []int64) (int64, int64, error)
	DeleteByUserID(ctx context.Context, id int64) (int64, error)
}

UserGroupsProvider ...

func NewUserGroupsRepository

func NewUserGroupsRepository(dbPool *sql.DB) UserGroupsProvider

NewUserGroupsRepository ...

type UserGroupsRepository

type UserGroupsRepository struct {
	UserGroupsRepositoryBase
	// contains filtered or unexported fields
}

UserGroupsRepository ...

func (*UserGroupsRepository) DeleteByUserID added in v0.8.4

func (ugr *UserGroupsRepository) DeleteByUserID(ctx context.Context, id int64) (int64, error)

DeleteByUserID removes user from all groups he belongs to.

func (*UserGroupsRepository) Exists

func (ugr *UserGroupsRepository) Exists(ctx context.Context, userID, groupID int64) (bool, error)

Exists implements UserGroupsProvider interface.

func (*UserGroupsRepository) Set

func (ugr *UserGroupsRepository) Set(ctx context.Context, userID int64, groupIDs []int64) (int64, int64, error)

Set implements UserGroupsProvider interface.

type UserGroupsRepositoryBase

type UserGroupsRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*UserGroupsRepositoryBase) BeginTx added in v0.18.0

func (*UserGroupsRepositoryBase) Count

func (*UserGroupsRepositoryBase) Find

func (*UserGroupsRepositoryBase) FindIter

func (*UserGroupsRepositoryBase) FindOneByUserIDAndGroupID

func (r *UserGroupsRepositoryBase) FindOneByUserIDAndGroupID(ctx context.Context, userGroupsUserID int64, userGroupsGroupID int64) (*UserGroupsEntity, error)

func (*UserGroupsRepositoryBase) FindQuery added in v0.9.0

func (r *UserGroupsRepositoryBase) FindQuery(fe *UserGroupsFindExpr) (string, []interface{}, error)

func (*UserGroupsRepositoryBase) Insert

func (*UserGroupsRepositoryBase) InsertQuery added in v0.9.0

func (r *UserGroupsRepositoryBase) InsertQuery(e *UserGroupsEntity, read bool) (string, []interface{}, error)

func (UserGroupsRepositoryBase) RunInTransaction added in v0.18.0

func (r UserGroupsRepositoryBase) RunInTransaction(ctx context.Context, fn func(rtx *UserGroupsRepositoryBaseTx) error, attempts int) (err error)

func (*UserGroupsRepositoryBase) Tx added in v0.18.0

func (*UserGroupsRepositoryBase) UpdateOneByUserIDAndGroupID

func (r *UserGroupsRepositoryBase) UpdateOneByUserIDAndGroupID(ctx context.Context, userGroupsUserID int64, userGroupsGroupID int64, p *UserGroupsPatch) (*UserGroupsEntity, error)

func (*UserGroupsRepositoryBase) UpdateOneByUserIDAndGroupIDQuery added in v0.9.0

func (r *UserGroupsRepositoryBase) UpdateOneByUserIDAndGroupIDQuery(userGroupsUserID int64, userGroupsGroupID int64, p *UserGroupsPatch) (string, []interface{}, error)

func (*UserGroupsRepositoryBase) Upsert

func (*UserGroupsRepositoryBase) UpsertQuery added in v0.9.0

func (r *UserGroupsRepositoryBase) UpsertQuery(e *UserGroupsEntity, p *UserGroupsPatch, inf ...string) (string, []interface{}, error)

type UserGroupsRepositoryBaseTx added in v0.18.0

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

func (UserGroupsRepositoryBaseTx) Commit added in v0.18.0

func (r UserGroupsRepositoryBaseTx) Commit() error

func (*UserGroupsRepositoryBaseTx) Count added in v0.18.0

func (*UserGroupsRepositoryBaseTx) Find added in v0.18.0

func (*UserGroupsRepositoryBaseTx) FindIter added in v0.18.0

func (*UserGroupsRepositoryBaseTx) Insert added in v0.18.0

func (UserGroupsRepositoryBaseTx) Rollback added in v0.18.0

func (r UserGroupsRepositoryBaseTx) Rollback() error

func (*UserGroupsRepositoryBaseTx) UpdateOneByUserIDAndGroupID added in v0.18.0

func (r *UserGroupsRepositoryBaseTx) UpdateOneByUserIDAndGroupID(ctx context.Context, userGroupsUserID int64, userGroupsGroupID int64, p *UserGroupsPatch) (*UserGroupsEntity, error)

func (*UserGroupsRepositoryBaseTx) Upsert added in v0.18.0

type UserIterator

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

UserIterator is not thread safe.

func (*UserIterator) Close

func (i *UserIterator) Close() error

func (*UserIterator) Columns

func (i *UserIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*UserIterator) Ent

func (i *UserIterator) Ent() (interface{}, error)

Ent is wrapper around User method that makes iterator more generic.

func (*UserIterator) Err

func (i *UserIterator) Err() error

func (*UserIterator) Next

func (i *UserIterator) Next() bool

func (*UserIterator) User

func (i *UserIterator) User() (*UserEntity, error)

type UserJoin added in v0.9.7

type UserJoin struct {
	On, Where    *UserCriteria
	Fetch        bool
	Kind         JoinType
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type UserPatch

type UserPatch struct {
	ConfirmationToken []byte
	CreatedAt         pq.NullTime
	CreatedBy         ntypes.Int64
	FirstName         ntypes.String
	IsActive          ntypes.Bool
	IsConfirmed       ntypes.Bool
	IsStaff           ntypes.Bool
	IsSuperuser       ntypes.Bool
	LastLoginAt       pq.NullTime
	LastName          ntypes.String
	Password          []byte
	UpdatedAt         pq.NullTime
	UpdatedBy         ntypes.Int64
	Username          ntypes.String
}

type UserPermissionsCountExpr added in v0.9.7

type UserPermissionsCountExpr struct {
	Where        *UserPermissionsCriteria
	JoinUser     *UserJoin
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type UserPermissionsCriteria

type UserPermissionsCriteria struct {
	CreatedAt           *qtypes.Timestamp
	CreatedBy           *qtypes.Int64
	PermissionAction    *qtypes.String
	PermissionModule    *qtypes.String
	PermissionSubsystem *qtypes.String
	UpdatedAt           *qtypes.Timestamp
	UpdatedBy           *qtypes.Int64
	UserID              *qtypes.Int64
	// contains filtered or unexported fields
}

func UserPermissionsAnd added in v0.18.0

func UserPermissionsAnd(operands ...*UserPermissionsCriteria) *UserPermissionsCriteria

func UserPermissionsOperand added in v0.18.0

func UserPermissionsOperand(operator string, operands ...*UserPermissionsCriteria) *UserPermissionsCriteria

func UserPermissionsOr added in v0.18.0

func UserPermissionsOr(operands ...*UserPermissionsCriteria) *UserPermissionsCriteria

type UserPermissionsEntity

type UserPermissionsEntity struct {
	// CreatedAt ...
	CreatedAt time.Time
	// CreatedBy ...
	CreatedBy ntypes.Int64
	// PermissionAction ...
	PermissionAction string
	// PermissionModule ...
	PermissionModule string
	// PermissionSubsystem ...
	PermissionSubsystem string
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// UpdatedBy ...
	UpdatedBy ntypes.Int64
	// UserID ...
	UserID int64
	// User ...
	User *UserEntity
	// Author ...
	Author *UserEntity
	// Modifier ...
	Modifier *UserEntity
}

UserPermissionsEntity ...

func ScanUserPermissionsRows

func ScanUserPermissionsRows(rows Rows) (entities []*UserPermissionsEntity, err error)

ScanUserPermissionsRows helps to scan rows straight to the slice of entities.

func (*UserPermissionsEntity) Prop

func (e *UserPermissionsEntity) Prop(cn string) (interface{}, bool)

func (*UserPermissionsEntity) Props

func (e *UserPermissionsEntity) Props(cns ...string) ([]interface{}, error)

type UserPermissionsFindExpr added in v0.9.7

type UserPermissionsFindExpr struct {
	Where         *UserPermissionsCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
	JoinUser      *UserJoin
	JoinAuthor    *UserJoin
	JoinModifier  *UserJoin
}

type UserPermissionsIterator

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

UserPermissionsIterator is not thread safe.

func (*UserPermissionsIterator) Close

func (i *UserPermissionsIterator) Close() error

func (*UserPermissionsIterator) Columns

func (i *UserPermissionsIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*UserPermissionsIterator) Ent

func (i *UserPermissionsIterator) Ent() (interface{}, error)

Ent is wrapper around UserPermissions method that makes iterator more generic.

func (*UserPermissionsIterator) Err

func (i *UserPermissionsIterator) Err() error

func (*UserPermissionsIterator) Next

func (i *UserPermissionsIterator) Next() bool

func (*UserPermissionsIterator) UserPermissions

func (i *UserPermissionsIterator) UserPermissions() (*UserPermissionsEntity, error)

type UserPermissionsJoin added in v0.9.7

type UserPermissionsJoin struct {
	On, Where    *UserPermissionsCriteria
	Fetch        bool
	Kind         JoinType
	JoinUser     *UserJoin
	JoinAuthor   *UserJoin
	JoinModifier *UserJoin
}

type UserPermissionsPatch

type UserPermissionsPatch struct {
	CreatedAt           pq.NullTime
	CreatedBy           ntypes.Int64
	PermissionAction    ntypes.String
	PermissionModule    ntypes.String
	PermissionSubsystem ntypes.String
	UpdatedAt           pq.NullTime
	UpdatedBy           ntypes.Int64
	UserID              ntypes.Int64
}

type UserPermissionsProvider

type UserPermissionsProvider interface {
	Insert(context.Context, *UserPermissionsEntity) (*UserPermissionsEntity, error)
	DeleteByUserID(context.Context, int64) (int64, error)
}

UserPermissionsProvider ...

func NewUserPermissionsRepository

func NewUserPermissionsRepository(dbPool *sql.DB) UserPermissionsProvider

NewUserPermissionsRepository ...

type UserPermissionsRepository

type UserPermissionsRepository struct {
	UserPermissionsRepositoryBase
	// contains filtered or unexported fields
}

UserPermissionsRepository extends UserPermissionsRepositoryBase

func (*UserPermissionsRepository) DeleteByUserID added in v0.8.4

func (upr *UserPermissionsRepository) DeleteByUserID(ctx context.Context, id int64) (int64, error)

DeleteByUserID removes all permissions of given user.

type UserPermissionsRepositoryBase

type UserPermissionsRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*UserPermissionsRepositoryBase) BeginTx added in v0.18.0

func (*UserPermissionsRepositoryBase) Count

func (*UserPermissionsRepositoryBase) Find

func (*UserPermissionsRepositoryBase) FindIter

func (*UserPermissionsRepositoryBase) FindOneByUserIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction

func (r *UserPermissionsRepositoryBase) FindOneByUserIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction(ctx context.Context, userPermissionsUserID int64, userPermissionsPermissionSubsystem string, userPermissionsPermissionModule string, userPermissionsPermissionAction string) (*UserPermissionsEntity, error)

func (*UserPermissionsRepositoryBase) FindQuery added in v0.9.0

func (r *UserPermissionsRepositoryBase) FindQuery(fe *UserPermissionsFindExpr) (string, []interface{}, error)

func (*UserPermissionsRepositoryBase) Insert

func (*UserPermissionsRepositoryBase) InsertQuery added in v0.9.0

func (r *UserPermissionsRepositoryBase) InsertQuery(e *UserPermissionsEntity, read bool) (string, []interface{}, error)

func (UserPermissionsRepositoryBase) RunInTransaction added in v0.18.0

func (r UserPermissionsRepositoryBase) RunInTransaction(ctx context.Context, fn func(rtx *UserPermissionsRepositoryBaseTx) error, attempts int) (err error)

func (*UserPermissionsRepositoryBase) Tx added in v0.18.0

func (*UserPermissionsRepositoryBase) UpdateOneByUserIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction

func (r *UserPermissionsRepositoryBase) UpdateOneByUserIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction(ctx context.Context, userPermissionsUserID int64, userPermissionsPermissionSubsystem string, userPermissionsPermissionModule string, userPermissionsPermissionAction string, p *UserPermissionsPatch) (*UserPermissionsEntity, error)

func (*UserPermissionsRepositoryBase) UpdateOneByUserIDAndPermissionSubsystemAndPermissionModuleAndPermissionActionQuery added in v0.9.0

func (r *UserPermissionsRepositoryBase) UpdateOneByUserIDAndPermissionSubsystemAndPermissionModuleAndPermissionActionQuery(userPermissionsUserID int64, userPermissionsPermissionSubsystem string, userPermissionsPermissionModule string, userPermissionsPermissionAction string, p *UserPermissionsPatch) (string, []interface{}, error)

func (*UserPermissionsRepositoryBase) Upsert

func (*UserPermissionsRepositoryBase) UpsertQuery added in v0.9.0

func (r *UserPermissionsRepositoryBase) UpsertQuery(e *UserPermissionsEntity, p *UserPermissionsPatch, inf ...string) (string, []interface{}, error)

type UserPermissionsRepositoryBaseTx added in v0.18.0

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

func (UserPermissionsRepositoryBaseTx) Commit added in v0.18.0

func (*UserPermissionsRepositoryBaseTx) Count added in v0.18.0

func (*UserPermissionsRepositoryBaseTx) Find added in v0.18.0

func (*UserPermissionsRepositoryBaseTx) FindIter added in v0.18.0

func (*UserPermissionsRepositoryBaseTx) Insert added in v0.18.0

func (UserPermissionsRepositoryBaseTx) Rollback added in v0.18.0

func (*UserPermissionsRepositoryBaseTx) UpdateOneByUserIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction added in v0.18.0

func (r *UserPermissionsRepositoryBaseTx) UpdateOneByUserIDAndPermissionSubsystemAndPermissionModuleAndPermissionAction(ctx context.Context, userPermissionsUserID int64, userPermissionsPermissionSubsystem string, userPermissionsPermissionModule string, userPermissionsPermissionAction string, p *UserPermissionsPatch) (*UserPermissionsEntity, error)

func (*UserPermissionsRepositoryBaseTx) Upsert added in v0.18.0

type UserProvider

type UserProvider interface {
	Exists(context.Context, int64) (bool, error)
	Create(context.Context, *UserEntity) (*UserEntity, error)
	Insert(context.Context, *UserEntity) (*UserEntity, error)
	CreateSuperuser(ctx context.Context, username string, password []byte, FirstName, LastName string) (*UserEntity, error)
	// Count retrieves number of all users.
	Count(context.Context) (int64, error)
	UpdateLastLoginAt(ctx context.Context, id int64) (int64, error)
	ChangePassword(ctx context.Context, id int64, password string) error
	Find(context.Context, *UserFindExpr) ([]*UserEntity, error)
	FindOneByID(context.Context, int64) (*UserEntity, error)
	FindOneByUsername(context.Context, string) (*UserEntity, error)
	DeleteOneByID(context.Context, int64) (int64, error)
	UpdateOneByID(context.Context, int64, *UserPatch) (*UserEntity, error)
	RegistrationConfirmation(ctx context.Context, id int64, confirmationToken string) (int64, error)
	IsGranted(ctx context.Context, id int64, permission charon.Permission) (bool, error)
	SetPermissions(ctx context.Context, id int64, permissions ...charon.Permission) (int64, int64, error)
}

UserProvider wraps UserRepository into interface.

type UserRepository

type UserRepository struct {
	UserRepositoryBase
}

UserRepository extends UserRepositoryBase.

func NewUserRepository

func NewUserRepository(dbPool *sql.DB) *UserRepository

NewUserRepository alocates new UserRepository instance

func (*UserRepository) ChangePassword

func (ur *UserRepository) ChangePassword(ctx context.Context, userID int64, password string) error

ChangePassword ...

func (*UserRepository) Count

func (ur *UserRepository) Count(ctx context.Context) (n int64, err error)

Count implements UserProvider interface.

func (*UserRepository) Create

func (ur *UserRepository) Create(ctx context.Context, ent *UserEntity) (*UserEntity, error)

Create implements UserProvider interface.

func (*UserRepository) CreateSuperuser

func (ur *UserRepository) CreateSuperuser(ctx context.Context, username string, password []byte, firstName, lastName string) (*UserEntity, error)

CreateSuperuser implements UserProvider interface.

func (*UserRepository) Exists

func (ur *UserRepository) Exists(ctx context.Context, userID int64) (bool, error)

Exists implements UserProvider interface.

func (*UserRepository) FindOneBy

func (ur *UserRepository) FindOneBy(ctx context.Context, fieldName string, value interface{}) (*UserEntity, error)

FindOneBy ...

func (*UserRepository) FindOneByUsername

func (ur *UserRepository) FindOneByUsername(ctx context.Context, username string) (*UserEntity, error)

FindOneByUsername ...

func (*UserRepository) IsGranted

func (ur *UserRepository) IsGranted(ctx context.Context, id int64, p charon.Permission) (bool, error)

IsGranted implements UserProvider interface.

func (*UserRepository) RegistrationConfirmation

func (ur *UserRepository) RegistrationConfirmation(ctx context.Context, userID int64, confirmationToken string) (int64, error)

RegistrationConfirmation ...

func (*UserRepository) SetPermissions

func (ur *UserRepository) SetPermissions(ctx context.Context, id int64, p ...charon.Permission) (int64, int64, error)

SetPermissions implements UserProvider interface.

func (*UserRepository) UpdateLastLoginAt

func (ur *UserRepository) UpdateLastLoginAt(ctx context.Context, userID int64) (int64, error)

UpdateLastLoginAt implements UserProvider interface.

type UserRepositoryBase

type UserRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*UserRepositoryBase) BeginTx added in v0.18.0

func (*UserRepositoryBase) Count

func (r *UserRepositoryBase) Count(ctx context.Context, exp *UserCountExpr) (int64, error)

func (*UserRepositoryBase) DeleteOneByID

func (r *UserRepositoryBase) DeleteOneByID(ctx context.Context, pk int64) (int64, error)

func (*UserRepositoryBase) Find

func (*UserRepositoryBase) FindIter

func (*UserRepositoryBase) FindOneByID

func (r *UserRepositoryBase) FindOneByID(ctx context.Context, pk int64) (*UserEntity, error)

func (*UserRepositoryBase) FindOneByIDAndUpdate added in v0.18.0

func (r *UserRepositoryBase) FindOneByIDAndUpdate(ctx context.Context, pk int64, p *UserPatch) (before, after *UserEntity, err error)

func (*UserRepositoryBase) FindOneByUsername

func (r *UserRepositoryBase) FindOneByUsername(ctx context.Context, userUsername string) (*UserEntity, error)

func (*UserRepositoryBase) FindQuery added in v0.9.0

func (r *UserRepositoryBase) FindQuery(fe *UserFindExpr) (string, []interface{}, error)

func (*UserRepositoryBase) Insert

func (*UserRepositoryBase) InsertQuery added in v0.9.0

func (r *UserRepositoryBase) InsertQuery(e *UserEntity, read bool) (string, []interface{}, error)

func (UserRepositoryBase) RunInTransaction added in v0.18.0

func (r UserRepositoryBase) RunInTransaction(ctx context.Context, fn func(rtx *UserRepositoryBaseTx) error, attempts int) (err error)

func (*UserRepositoryBase) Tx added in v0.18.0

func (*UserRepositoryBase) UpdateOneByID

func (r *UserRepositoryBase) UpdateOneByID(ctx context.Context, pk int64, p *UserPatch) (*UserEntity, error)

func (*UserRepositoryBase) UpdateOneByIDQuery added in v0.9.0

func (r *UserRepositoryBase) UpdateOneByIDQuery(pk int64, p *UserPatch) (string, []interface{}, error)

func (*UserRepositoryBase) UpdateOneByUsername

func (r *UserRepositoryBase) UpdateOneByUsername(ctx context.Context, userUsername string, p *UserPatch) (*UserEntity, error)

func (*UserRepositoryBase) UpdateOneByUsernameQuery added in v0.9.0

func (r *UserRepositoryBase) UpdateOneByUsernameQuery(userUsername string, p *UserPatch) (string, []interface{}, error)

func (*UserRepositoryBase) Upsert

func (r *UserRepositoryBase) Upsert(ctx context.Context, e *UserEntity, p *UserPatch, inf ...string) (*UserEntity, error)

func (*UserRepositoryBase) UpsertQuery added in v0.9.0

func (r *UserRepositoryBase) UpsertQuery(e *UserEntity, p *UserPatch, inf ...string) (string, []interface{}, error)

type UserRepositoryBaseTx added in v0.18.0

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

func (UserRepositoryBaseTx) Commit added in v0.18.0

func (r UserRepositoryBaseTx) Commit() error

func (*UserRepositoryBaseTx) Count added in v0.18.0

func (*UserRepositoryBaseTx) DeleteOneByID added in v0.18.0

func (r *UserRepositoryBaseTx) DeleteOneByID(ctx context.Context, pk int64) (int64, error)

func (*UserRepositoryBaseTx) Find added in v0.18.0

func (*UserRepositoryBaseTx) FindIter added in v0.18.0

func (*UserRepositoryBaseTx) FindOneByID added in v0.18.0

func (r *UserRepositoryBaseTx) FindOneByID(ctx context.Context, pk int64) (*UserEntity, error)

func (*UserRepositoryBaseTx) Insert added in v0.18.0

func (UserRepositoryBaseTx) Rollback added in v0.18.0

func (r UserRepositoryBaseTx) Rollback() error

func (*UserRepositoryBaseTx) UpdateOneByID added in v0.18.0

func (r *UserRepositoryBaseTx) UpdateOneByID(ctx context.Context, pk int64, p *UserPatch) (*UserEntity, error)

func (*UserRepositoryBaseTx) UpdateOneByUsername added in v0.18.0

func (r *UserRepositoryBaseTx) UpdateOneByUsername(ctx context.Context, userUsername string, p *UserPatch) (*UserEntity, error)

func (*UserRepositoryBaseTx) Upsert added in v0.18.0

func (r *UserRepositoryBaseTx) Upsert(ctx context.Context, e *UserEntity, p *UserPatch, inf ...string) (*UserEntity, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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