model

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2017 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

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"
	TableUserConstraintUsernameUnique = "charon.user_username_key"

	TableUserConstraintPrimaryKey = "charon.user_id_pkey"

	TableUserConstraintCreatedByForeignKey = "charon.user_created_by_fkey"

	TableUserConstraintUpdatedByForeignKey = "charon.user_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"
	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 (
	TablePermission                                      = "charon.permission"
	TablePermissionColumnAction                          = "action"
	TablePermissionColumnCreatedAt                       = "created_at"
	TablePermissionColumnID                              = "id"
	TablePermissionColumnModule                          = "module"
	TablePermissionColumnSubsystem                       = "subsystem"
	TablePermissionColumnUpdatedAt                       = "updated_at"
	TablePermissionConstraintSubsystemModuleActionUnique = "charon.permission_subsystem_module_action_key"

	TablePermissionConstraintPrimaryKey = "charon.permission_id_pkey"
)
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"
	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 (
	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"
	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 (
	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"
	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 (
	JoinDoNot = iota
	JoinInner
	JoinLeft
	JoinRight
	JoinCross
)
View Source
const SQL = `` /* 4404-byte string literal not displayed */
View Source
const (
	// UserConfirmationTokenUsed ...
	UserConfirmationTokenUsed = "!"
)

Variables

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("!")
)

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 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
}

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)

func (*GroupEntity) Message

func (ge *GroupEntity) Message() (*charonrpc.Group, error)

Message maps entity into protobuf message.

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       map[string]bool
	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
}

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)

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       map[string]bool
	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) 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) 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 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(ctx context.Context, id, updatedBy int64, name, description *ntypes.String) (*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
}

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 ...

func (*GroupRepository) UpdateOneByID

func (gr *GroupRepository) UpdateOneByID(ctx context.Context, id, updatedBy int64, name, description *ntypes.String) (*GroupEntity, error)

UpdateOneByID ...

type GroupRepositoryBase

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

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) 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) 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 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) 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 MockCompositionWriter added in v0.9.0

type MockCompositionWriter struct {
	mock.Mock
}

func (*MockCompositionWriter) WriteComposition added in v0.9.0

func (_m *MockCompositionWriter) WriteComposition(_a0 string, _a1 *Composer, _a2 *CompositionOpts) error

WriteComposition provides a mock function with given fields: _a0, _a1, _a2

type MockGroupPermissionsProvider

type MockGroupPermissionsProvider struct {
	mock.Mock
}

func (*MockGroupPermissionsProvider) Insert

Insert provides a mock function with given fields: _a0, _a1

type MockGroupProvider

type MockGroupProvider struct {
	mock.Mock
}

func (*MockGroupProvider) Create

func (_m *MockGroupProvider) Create(ctx context.Context, createdBy int64, name string, description *ntypes.String) (*GroupEntity, error)

Create provides a mock function with given fields: ctx, createdBy, name, description

func (*MockGroupProvider) DeleteOneByID

func (_m *MockGroupProvider) DeleteOneByID(_a0 context.Context, _a1 int64) (int64, error)

DeleteOneByID provides a mock function with given fields: _a0, _a1

func (*MockGroupProvider) Find

func (_m *MockGroupProvider) Find(_a0 context.Context, _a1 *GroupFindExpr) ([]*GroupEntity, error)

Find provides a mock function with given fields: _a0, _a1

func (*MockGroupProvider) FindByUserID

func (_m *MockGroupProvider) FindByUserID(_a0 context.Context, _a1 int64) ([]*GroupEntity, error)

FindByUserID provides a mock function with given fields: _a0, _a1

func (*MockGroupProvider) FindOneByID

func (_m *MockGroupProvider) FindOneByID(_a0 context.Context, _a1 int64) (*GroupEntity, error)

FindOneByID provides a mock function with given fields: _a0, _a1

func (*MockGroupProvider) Insert

func (_m *MockGroupProvider) Insert(_a0 context.Context, _a1 *GroupEntity) (*GroupEntity, error)

Insert provides a mock function with given fields: _a0, _a1

func (*MockGroupProvider) IsGranted

func (_m *MockGroupProvider) IsGranted(_a0 context.Context, _a1 int64, _a2 charon.Permission) (bool, error)

IsGranted provides a mock function with given fields: _a0, _a1, _a2

func (*MockGroupProvider) SetPermissions

func (_m *MockGroupProvider) SetPermissions(_a0 context.Context, _a1 int64, _a2 ...charon.Permission) (int64, int64, error)

SetPermissions provides a mock function with given fields: _a0, _a1, _a2

func (*MockGroupProvider) UpdateOneByID

func (_m *MockGroupProvider) UpdateOneByID(ctx context.Context, id int64, updatedBy int64, name *ntypes.String, description *ntypes.String) (*GroupEntity, error)

UpdateOneByID provides a mock function with given fields: ctx, id, updatedBy, name, description

type MockPermissionProvider

type MockPermissionProvider struct {
	mock.Mock
}

func (*MockPermissionProvider) Find

Find provides a mock function with given fields: ctx, criteria

func (*MockPermissionProvider) FindByGroupID

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

FindByGroupID provides a mock function with given fields: ctx, groupID

func (*MockPermissionProvider) FindByUserID

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

FindByUserID provides a mock function with given fields: ctx, userID

func (*MockPermissionProvider) FindOneByID

func (_m *MockPermissionProvider) FindOneByID(ctx context.Context, id int64) (*PermissionEntity, error)

FindOneByID provides a mock function with given fields: ctx, id

func (*MockPermissionProvider) Insert

Insert provides a mock function with given fields: ctx, entity

func (*MockPermissionProvider) Register

func (_m *MockPermissionProvider) Register(ctx context.Context, permissions charon.Permissions) (int64, int64, int64, error)

Register provides a mock function with given fields: ctx, permissions

type MockPermissionRegistry

type MockPermissionRegistry struct {
	mock.Mock
}

func (*MockPermissionRegistry) Exists

func (_m *MockPermissionRegistry) Exists(ctx context.Context, permission charon.Permission) bool

Exists provides a mock function with given fields: ctx, permission

func (*MockPermissionRegistry) Register

func (_m *MockPermissionRegistry) Register(ctx context.Context, permissions charon.Permissions) (int64, int64, int64, error)

Register provides a mock function with given fields: ctx, permissions

type MockRows added in v0.10.0

type MockRows struct {
	mock.Mock
}

func (*MockRows) ColumnTypes added in v0.10.0

func (_m *MockRows) ColumnTypes() ([]*sql.ColumnType, error)

ColumnTypes provides a mock function with given fields:

func (*MockRows) Columns added in v0.10.0

func (_m *MockRows) Columns() ([]string, error)

Columns provides a mock function with given fields:

func (*MockRows) Err added in v0.10.0

func (_m *MockRows) Err() error

Err provides a mock function with given fields:

func (*MockRows) Next added in v0.10.0

func (_m *MockRows) Next() bool

Next provides a mock function with given fields:

func (*MockRows) NextResultSet added in v0.10.0

func (_m *MockRows) NextResultSet() bool

NextResultSet provides a mock function with given fields:

func (*MockRows) Scan added in v0.10.0

func (_m *MockRows) Scan(dest ...interface{}) error

Scan provides a mock function with given fields: dest

type MockUserGroupsProvider

type MockUserGroupsProvider struct {
	mock.Mock
}

func (*MockUserGroupsProvider) DeleteByUserID added in v0.8.4

func (_m *MockUserGroupsProvider) DeleteByUserID(ctx context.Context, id int64) (int64, error)

DeleteByUserID provides a mock function with given fields: ctx, id

func (*MockUserGroupsProvider) Exists

func (_m *MockUserGroupsProvider) Exists(ctx context.Context, userID int64, groupID int64) (bool, error)

Exists provides a mock function with given fields: ctx, userID, groupID

func (*MockUserGroupsProvider) Find

Find provides a mock function with given fields: ctx, expr

func (*MockUserGroupsProvider) Insert

Insert provides a mock function with given fields: ctx, ent

func (*MockUserGroupsProvider) Set

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

Set provides a mock function with given fields: ctx, userID, groupIDs

type MockUserPermissionsProvider

type MockUserPermissionsProvider struct {
	mock.Mock
}

func (*MockUserPermissionsProvider) DeleteByUserID added in v0.8.4

func (_m *MockUserPermissionsProvider) DeleteByUserID(_a0 context.Context, _a1 int64) (int64, error)

DeleteByUserID provides a mock function with given fields: _a0, _a1

func (*MockUserPermissionsProvider) Insert

Insert provides a mock function with given fields: _a0, _a1

type MockUserProvider

type MockUserProvider struct {
	mock.Mock
}

func (*MockUserProvider) ChangePassword

func (_m *MockUserProvider) ChangePassword(ctx context.Context, id int64, password string) error

ChangePassword provides a mock function with given fields: ctx, id, password

func (*MockUserProvider) Count

func (_m *MockUserProvider) Count(_a0 context.Context) (int64, error)

Count provides a mock function with given fields: _a0

func (*MockUserProvider) Create

func (_m *MockUserProvider) Create(ctx context.Context, username string, password []byte, FirstName string, LastName string, confirmationToken []byte, isSuperuser bool, IsStaff bool, isActive bool, isConfirmed bool) (*UserEntity, error)

Create provides a mock function with given fields: ctx, username, password, FirstName, LastName, confirmationToken, isSuperuser, IsStaff, isActive, isConfirmed

func (*MockUserProvider) CreateSuperuser

func (_m *MockUserProvider) CreateSuperuser(ctx context.Context, username string, password []byte, FirstName string, LastName string) (*UserEntity, error)

CreateSuperuser provides a mock function with given fields: ctx, username, password, FirstName, LastName

func (*MockUserProvider) DeleteOneByID

func (_m *MockUserProvider) DeleteOneByID(_a0 context.Context, _a1 int64) (int64, error)

DeleteOneByID provides a mock function with given fields: _a0, _a1

func (*MockUserProvider) Exists

func (_m *MockUserProvider) Exists(_a0 context.Context, _a1 int64) (bool, error)

Exists provides a mock function with given fields: _a0, _a1

func (*MockUserProvider) Find

func (_m *MockUserProvider) Find(_a0 context.Context, _a1 *UserFindExpr) ([]*UserEntity, error)

Find provides a mock function with given fields: _a0, _a1

func (*MockUserProvider) FindOneByID

func (_m *MockUserProvider) FindOneByID(_a0 context.Context, _a1 int64) (*UserEntity, error)

FindOneByID provides a mock function with given fields: _a0, _a1

func (*MockUserProvider) FindOneByUsername

func (_m *MockUserProvider) FindOneByUsername(_a0 context.Context, _a1 string) (*UserEntity, error)

FindOneByUsername provides a mock function with given fields: _a0, _a1

func (*MockUserProvider) Insert

func (_m *MockUserProvider) Insert(_a0 context.Context, _a1 *UserEntity) (*UserEntity, error)

Insert provides a mock function with given fields: _a0, _a1

func (*MockUserProvider) IsGranted

func (_m *MockUserProvider) IsGranted(ctx context.Context, id int64, permission charon.Permission) (bool, error)

IsGranted provides a mock function with given fields: ctx, id, permission

func (*MockUserProvider) RegistrationConfirmation

func (_m *MockUserProvider) RegistrationConfirmation(ctx context.Context, id int64, confirmationToken string) (int64, error)

RegistrationConfirmation provides a mock function with given fields: ctx, id, confirmationToken

func (*MockUserProvider) SetPermissions

func (_m *MockUserProvider) SetPermissions(ctx context.Context, id int64, permissions ...charon.Permission) (int64, int64, error)

SetPermissions provides a mock function with given fields: ctx, id, permissions

func (*MockUserProvider) UpdateLastLoginAt

func (_m *MockUserProvider) UpdateLastLoginAt(ctx context.Context, id int64) (int64, error)

UpdateLastLoginAt provides a mock function with given fields: ctx, id

func (*MockUserProvider) UpdateOneByID

func (_m *MockUserProvider) UpdateOneByID(_a0 context.Context, _a1 int64, _a2 *UserPatch) (*UserEntity, error)

UpdateOneByID provides a mock function with given fields: _a0, _a1, _a2

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
}

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)

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       map[string]bool
}

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

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, userID 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) 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) 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) 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) 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 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(dest ...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
}

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)

func (*UserEntity) Message

func (ue *UserEntity) Message() (*charonrpc.User, error)

Message maps entity into protobuf message.

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       map[string]bool
	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
}

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)

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       map[string]bool
	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) 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) 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 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
}

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)

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       map[string]bool
	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) 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) 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 UserProvider

type UserProvider interface {
	Exists(context.Context, int64) (bool, error)
	Create(ctx context.Context, username string, password []byte, FirstName, LastName string, confirmationToken []byte, isSuperuser, IsStaff, isActive, isConfirmed bool) (*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, username string, password []byte, firstName, lastName string, confirmationToken []byte, isSuperuser, isStaff, isActive, isConfirmed bool) (*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) Count

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

Jump to

Keyboard shortcuts

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