model

package
v0.0.0-...-e81234b Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OwnerPerm defines the general permission for an owner.
	OwnerPerm = "owner"

	// AdminPerm defines the general permission for an admin.
	AdminPerm = "admin"

	// UserPerm defines the general permission for an user.
	UserPerm = "user"
)
View Source
const (
	// UserGroupOwnerPerm defines the permission for an owner on user groups.
	UserGroupOwnerPerm = OwnerPerm

	// UserGroupAdminPerm defines the permission for an admin on user groups.
	UserGroupAdminPerm = AdminPerm

	// UserGroupUserPerm defines the permission for an user on user groups.
	UserGroupUserPerm = UserPerm
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	bun.BaseModel `bun:"table:groups"`

	ID        string       `bun:",pk,type:varchar(20)"`
	Scim      string       `bun:"type:varchar(255)"`
	Slug      string       `bun:",unique,type:varchar(255)"`
	Name      string       `bun:"type:varchar(255)"`
	CreatedAt time.Time    `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time    `bun:",nullzero,notnull,default:current_timestamp"`
	Users     []*UserGroup `bun:"rel:has-many,join:id=group_id"`
}

Group defines the model for groups table.

func (*Group) BeforeAppendModel

func (m *Group) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type ListParams

type ListParams struct {
	Search string
	Sort   string
	Order  string
	Limit  int64
	Offset int64
}

ListParams defines optional list attributes.

type User

type User struct {
	bun.BaseModel `bun:"table:users"`

	ID        string       `bun:",pk,type:varchar(20)"`
	Scim      string       `bun:"type:varchar(255)"`
	Username  string       `bun:",unique,type:varchar(255)"`
	Password  string       `bun:"-"`
	Hashword  string       `bun:"type:varchar(255)"`
	Email     string       `bun:"type:varchar(255)"`
	Fullname  string       `bun:"type:varchar(255)"`
	Profile   string       `bun:"-"`
	Active    bool         `bun:"default:false"`
	Admin     bool         `bun:"default:false"`
	CreatedAt time.Time    `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time    `bun:",nullzero,notnull,default:current_timestamp"`
	Auths     []*UserAuth  `bun:"rel:has-many,join:id=user_id"`
	Groups    []*UserGroup `bun:"rel:has-many,join:id=user_id"`
}

User defines the model for users table.

func (*User) BeforeAppendModel

func (m *User) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type UserAuth

type UserAuth struct {
	bun.BaseModel `bun:"table:user_auths"`

	ID        string    `bun:",pk,type:varchar(20)"`
	UserID    string    `bun:"type:varchar(20)"`
	User      *User     `bun:"rel:belongs-to,join:user_id=id"`
	Provider  string    `bun:"type:varchar(255)"`
	Ref       string    `bun:"type:varchar(255)"`
	Login     string    `bun:"type:varchar(255)"`
	Email     string    `bun:"type:varchar(255)"`
	Name      string    `bun:"type:varchar(255)"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

UserAuth defines the model for user_auths table.

func (*UserAuth) BeforeAppendModel

func (m *UserAuth) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type UserGroup

type UserGroup struct {
	bun.BaseModel `bun:"table:user_groups"`

	UserID    string    `bun:",pk,type:varchar(20)"`
	User      *User     `bun:"rel:belongs-to,join:user_id=id"`
	GroupID   string    `bun:",pk,type:varchar(20)"`
	Group     *Group    `bun:"rel:belongs-to,join:group_id=id"`
	Perm      string    `bun:"type:varchar(32)"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

UserGroup defines the model for user_groups table.

func (*UserGroup) BeforeAppendModel

func (m *UserGroup) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type UserGroupParams

type UserGroupParams struct {
	ListParams

	UserID  string
	GroupID string
	Perm    string
}

UserGroupParams defines parameters for user groups.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳