models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACUART               = "uart"
	AppDefaultAdminScope = "all:all"
	AppDefaultScope      = "profile, auth:all"

	DefaultSortApps = "name"
)

default values

View Source
const (
	MsgFacCore  = "core"
	MsgFacAuth  = "auth"
	MsgFacApp   = "app"
	MsgFacUser  = "user"
	MsgFacMesg  = "messaging"
	MsgFacCron  = "scheduler"
	MsgFacSecu  = "security"
	MsgPriEmerg = 0 // RESERVED
	MsgPriAlert = 1 // for alert
	MsgPriCrit  = 2 // FATAL
	MsgPriErr   = 3
	MsgPriWarn  = 4
	MsgPriNote  = 5 // for notification
	MsgPriInfo  = 6
	MsgPriDebug = 7
)

constants for messaging/logging subsystem

View Source
const (
	RCAdmin   = "admin"
	RCUser    = "user"
	RCAppMan  = "appman"
	RCUserMan = "userman"
	RCLeader  = "leader"
)

standard role codes

View Source
const (
	DefaultSortCredentials = "created_at"
)

common constants

View Source
const (
	DefaultSortMembers = "created_at"
)

common constants

View Source
const (
	DefaultSortMessages = "created_at desc"
)

common constants

Variables

DB and others: shared variables for models

View Source
var MessengerMethod = map[string]string{
	"Email": "mail",
}

MessengerMethod is a map for method name to code string.

View Source
var MessengerMethodReverse = map[string]string{
	"mail": "Email",
}

MessengerMethodReverse is a reverse map for method code to name.

View Source
var MessengerPriority = map[string]int{
	"Alert":        1,
	"Notification": 5,
	"Disabled":     8,
}

MessengerPriority is a map for priority string to code.

View Source
var MsgPri = map[string]int{
	"Emerg": 0,
	"Alert": 1,
	"Crit":  2,
	"Err":   3,
	"Warn":  4,
	"Note":  5,
	"Info":  6,
	"Debug": 7,
}

MsgPri is a map for name to code referencing of message priority

View Source
var MsgPriReverse = map[int]string{
	0: "Emerg",
	1: "Alert",
	2: "Crit",
	3: "Err",
	4: "Warn",
	5: "Note",
	6: "Info",
	7: "Debug",
}

MsgPriReverse is a map for code to name referencing of message priority

Functions

func AllMy

func AllMy(q *pop.Query, m *Member, b Belonging, all ...bool) error

AllMy collect all instances of belongings accessible by owner.

func AllMyOwn

func AllMyOwn(q *pop.Query, m *Member, b Belonging, all ...bool) error

AllMyOwn collect all instances of belongings accessible by owner.

func FindMy

func FindMy(q *pop.Query, m *Member, b Belonging, id interface{}) error

FindMy find a single instance of belonging accessible by owner.

func FindMyOwn

func FindMyOwn(q *pop.Query, m *Member, b Belonging, id interface{}) error

FindMyOwn find a single instance of belonging accessible by owner.

func Logger

func Logger(logger buffalo.Logger)

Logger set logger for models.

func Marshal

func Marshal(m Object) string

Marshal returns JSON marshalled string from given object

func SelectByAttrs

func SelectByAttrs(m interface{}, attrs map[string]interface{}) error

SelectByAttrs find and store models with given search attributes

Types

type AccessGrant

type AccessGrant struct {
	ID          uuid.UUID `json:"id" db:"id"`
	CreatedAt   time.Time `json:"created_at" db:"created_at"`
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at"`
	AppID       uuid.UUID `json:"app_id" db:"app_id"`
	MemberID    uuid.UUID `json:"member_id" db:"member_id"`
	Scope       string    `json:"scope" db:"scope"`
	AccessCount int       `json:"access_count" db:"access_count"`
}

AccessGrant is the linkage between Member and App.

func (AccessGrant) App

func (g AccessGrant) App() *App

App returns the associated app instance

func (AccessGrant) Description

func (g AccessGrant) Description() template.HTML

Description returns formatted description of the access grant

func (AccessGrant) Member

func (g AccessGrant) Member() *Member

Member returns the associcated member instance

func (AccessGrant) String

func (g AccessGrant) String() string

String returns pretty printable string of this model.

func (*AccessGrant) Validate

func (g *AccessGrant) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate" method.

type AccessGrants

type AccessGrants []AccessGrant

AccessGrants is array of AccessGrants

type App

type App struct {
	ID          uuid.UUID `json:"id" db:"id"`
	CreatedAt   time.Time `json:"created_at" db:"created_at"`
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at"`
	Name        string    `json:"name" db:"name"`
	Code        string    `json:"code" db:"code"`
	Description string    `json:"description" db:"description"`
	AppKey      string    `json:"app_key" db:"app_key"`
	AppSecret   string    `json:"app_secret" db:"app_secret"`
	SiteURL     string    `json:"site_url" db:"site_url"`
	CallbackURL string    `json:"callback_url" db:"callback_url"`
	AppIcon     string    `json:"app_icon" db:"app_icon"`
}

App is model for application which can be authenticated with uart.

func GetAppByCode

func GetAppByCode(code string) *App

GetAppByCode search and returns an app instance by given code, or nil

func GetAppByKey

func GetAppByKey(key string) *App

GetAppByKey returns an app instance has given app_key or nil.

func NewApp

func NewApp(name, code, desc, url, callback string, icon ...string) *App

NewApp create an app with given values.

func (*App) AccessibleBy

func (a *App) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (*App) AddRole

func (a *App) AddRole(tx *pop.Connection, n, c, d string, r int, o bool) error

AddRole create role for the app.

func (*App) GenerateKeyPair

func (a *App) GenerateKeyPair()

GenerateKeyPair generates key and secret for the app.

func (*App) GetRole

func (a *App) GetRole(tx *pop.Connection, code string) *Role

GetRole returns a role with given code of the app or nil.

func (App) GetRoles

func (a App) GetRoles() *Roles

GetRoles returns array of roles of the app

func (App) GrantsCount

func (a App) GrantsCount() int

GrantsCount returns count of access grant for the app

func (*App) OwnedBy

func (a *App) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (*App) QueryParams

func (a *App) QueryParams() QueryParams

QueryParams implements Belonging interface

func (App) Requests

func (a App) Requests() *[]RoleMap

Requests returns array of inactive rolemaps

func (App) RequestsCount

func (a App) RequestsCount() int

RequestsCount returns count of role requests for the app

func (App) String

func (a App) String() string

String returns pretty printable string of this model.

func (*App) Validate

func (a *App) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate" method.

func (*App) ValidateSave

func (a *App) ValidateSave(tx *pop.Connection) (*validate.Errors, error)

ValidateSave gets run every time you call "pop.ValidateSave" method.

func (*App) ValidateUpdate

func (a *App) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateUpdate" method.

type Apps

type Apps []App

Apps is array of App.

func (*Apps) AccessibleBy

func (a *Apps) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (*Apps) OwnedBy

func (a *Apps) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (*Apps) QueryParams

func (a *Apps) QueryParams() QueryParams

QueryParams implements Belonging interface

type Belonging

type Belonging interface {
	QueryParams() QueryParams
	OwnedBy(*pop.Query, Owner, ...bool) *pop.Query
	AccessibleBy(*pop.Query, Owner, ...bool) *pop.Query
}

Belonging is an interface for model which have foreign reference.

type Credential

type Credential struct {
	ID           uuid.UUID `json:"id" db:"id"`
	CreatedAt    time.Time `json:"created_at" db:"created_at"`
	UpdatedAt    time.Time `json:"updated_at" db:"updated_at"`
	MemberID     uuid.UUID `json:"member_id" db:"member_id"`
	Provider     string    `json:"provider" db:"provider"`
	UserID       string    `json:"user_id" db:"user_id"`
	Name         string    `json:"name" db:"name"`
	Email        string    `json:"email" db:"email"`
	AvatarURL    string    `json:"avatar_url" db:"avatar_url"`
	IsAuthorized bool      `json:"is_authorized" db:"is_authorized"`
	IsPrimary    bool      `json:"is_primary" db:"is_primary"`
}

Credential is the model for oauth2 information from 3rd party providers

func (*Credential) AccessibleBy

func (c *Credential) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (*Credential) OwnedBy

func (c *Credential) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (Credential) Owner

func (c Credential) Owner() *Member

Owner find and return associated member instance

func (Credential) OwnerID

func (c Credential) OwnerID() uuid.UUID

OwnerID returns id of associated member

func (*Credential) QueryParams

func (c *Credential) QueryParams() QueryParams

QueryParams implements Belonging interface

func (*Credential) Save

func (c *Credential) Save()

Save just save self.

func (Credential) String

func (c Credential) String() string

String returns pretty printable string of this model.

type Credentials

type Credentials []Credential

Credentials is an array of Credentials.

func (*Credentials) AccessibleBy

func (c *Credentials) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (*Credentials) OwnedBy

func (c *Credentials) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (*Credentials) QueryParams

func (c *Credentials) QueryParams() QueryParams

QueryParams implements Belonging interface

type Doc

type Doc struct {
	ID          uuid.UUID `json:"id" db:"id"`
	CreatedAt   time.Time `json:"created_at" db:"created_at"`
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at"`
	MemberID    uuid.UUID `json:"member_id" db:"member_id"`
	Type        string    `json:"type" db:"type"`
	Category    string    `json:"category" db:"category"`
	Subject     string    `json:"subject" db:"subject"`
	Slug        string    `json:"slug" db:"slug"`
	Title       string    `json:"title" db:"title"`
	Content     string    `json:"content" db:"content"`
	IsPublished bool      `json:"is_published" db:"is_published"`
	NewCategory string    `json:"new_category" db:"-"`
	NewSubject  string    `json:"new_subject" db:"-"`
}

Doc is a structure for documentations

func (*Doc) AccessibleBy

func (d *Doc) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (Doc) AuthorName

func (d Doc) AuthorName() string

AuthorName returns name of the author associated to the doc.

func (*Doc) OwnedBy

func (d *Doc) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (*Doc) QueryParams

func (d *Doc) QueryParams() QueryParams

QueryParams implements Belonging interface

func (Doc) String

func (d Doc) String() string

String returns title of the document

func (*Doc) Validate

func (d *Doc) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate" method.

func (*Doc) ValidateSave

func (d *Doc) ValidateSave(tx *pop.Connection) (*validate.Errors, error)

ValidateSave gets run every time you call "pop.ValidateSave" method.

func (*Doc) ValidateUpdate

func (d *Doc) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateUpdate" method.

type Docs

type Docs []Doc

Docs is an array of Docs

type Member

type Member struct {
	ID        uuid.UUID `json:"id" db:"id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
	Name      string    `json:"name" db:"name"`
	Email     string    `json:"email" db:"email"`
	Mobile    string    `json:"mobile" db:"mobile"`
	Icon      string    `json:"icon" db:"icon"`
	IsActive  bool      `json:"is_active" db:"is_active"`
	Note      string    `json:"note" db:"note"`
	APIKey    string    `json:"api_key" db:"api_key"`
}

Member is the main model which presents the user.

func CreateMember

func CreateMember(cred *Credential) (*Member, error)

CreateMember creates a member with an associated credential

func GetMember

func GetMember(id interface{}) *Member

GetMember picks a member instance with given id.

func (Member) AccessGrantCount

func (m Member) AccessGrantCount() int

AccessGrantCount returns count of associated access grants

func (*Member) AccessibleBy

func (m *Member) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (*Member) AddRole

func (m *Member) AddRole(tx *pop.Connection, r *Role, active ...bool) error

AddRole create mapping object for the member.

func (Member) AppRoles

func (m Member) AppRoles(appID uuid.UUID, flag ...bool) *Roles

AppRoles returns associated roles of given app, assigned to the member.

func (Member) CredentialCount

func (m Member) CredentialCount() int

CredentialCount returns count of associated credentials

func (Member) Credentials

func (m Member) Credentials() *Credentials

Credentials returns the member's associated credentials

func (Member) GetAppRoleCodes

func (m Member) GetAppRoleCodes(appCode string) []string

GetAppRoleCodes returns the member's active role codes of given app.

func (*Member) GetID

func (m *Member) GetID() interface{}

GetID implements Owner interface

func (Member) Grant

func (m Member) Grant(tx *pop.Connection, app *App, scope string) error

Grant create an access grant for given member to the app

func (Member) Granted

func (m Member) Granted(appID uuid.UUID, scope string) bool

Granted checks if the member have granted for given app. additionally it increase reference count as access count.

func (Member) GrantedApps

func (m Member) GrantedApps() *Apps

GrantedApps returns the member's associcated granted apps

func (Member) Grants

func (m Member) Grants() *AccessGrants

Grants returns all grants of the member.

func (Member) HasRole

func (m Member) HasRole(roleID uuid.UUID) bool

HasRole return true if the member has the role regardless of activated.

func (*Member) IsNil

func (m *Member) IsNil() bool

IsNil return true if the member's ID is nil. otherwise return true.

func (*Member) MessageMarkAsSent

func (m *Member) MessageMarkAsSent(id uuid.UUID) error

MessageMarkAsSent marks given message's message map for the member.

func (*Member) Messengers

func (m *Member) Messengers(args ...int) *Messengers

Messengers returns messengers belonging to the member.

func (*Member) OwnedBy

func (m *Member) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (*Member) PrimaryAlert

func (m *Member) PrimaryAlert() *Messenger

PrimaryAlert returns primary messenger of the member.

func (*Member) PrimaryNotifier

func (m *Member) PrimaryNotifier() *Messenger

PrimaryNotifier returns primary messenger of the member.

func (*Member) QueryParams

func (m *Member) QueryParams() QueryParams

QueryParams implements Belonging interface

func (*Member) RemoveRole

func (m *Member) RemoveRole(tx *pop.Connection, r *Role) error

RemoveRole remove rolemap between the member and given role.

func (Member) Revoke

func (m Member) Revoke(tx *pop.Connection, app *App) error

Revoke decouples the app and given member, returns database status Revoke does not consider scope.

func (Member) Roles

func (m Member) Roles() *Roles

Roles returns the member's associcated roles

func (*Member) Save

func (m *Member) Save()

Save just save self.

func (Member) String

func (m Member) String() string

String returns pretty printable string of this model.

func (*Member) Validate

func (m *Member) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate" method.

func (*Member) ValidateSave

func (m *Member) ValidateSave(tx *pop.Connection) (*validate.Errors, error)

ValidateSave gets run every time you call "pop.ValidateSave" method.

func (*Member) ValidateUpdate

func (m *Member) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateUpdate" method.

type Members

type Members []Member

Members is an array of Members.

func (*Members) AccessibleBy

func (m *Members) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (*Members) OwnedBy

func (m *Members) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (*Members) QueryParams

func (m *Members) QueryParams() QueryParams

QueryParams implements Belonging interface

type Message

type Message struct {
	ID        uuid.UUID `json:"id" db:"id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
	MemberID  uuid.UUID `json:"member_id" db:"member_id"`
	Subject   string    `json:"subject" db:"subject"`
	Content   string    `json:"content" db:"content"`
	AppCode   string    `json:"app_code" db:"app_code"`
	Facility  string    `json:"facility" db:"facility"`
	Priority  int       `json:"priority" db:"priority"`
	IsLog     bool      `json:"is_log" db:"is_log"`
}

Message is a structure for messaging/logging subsystem

func NewMessage

func NewMessage(tx *pop.Connection, sndrID interface{}, rcpts, bccs *Members, subj, cont, ac, fac string, pri int, isLog bool) *Message

NewMessage creates new message with given parameters

func (*Message) AccessibleBy

func (m *Message) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (Message) AppName

func (m Message) AppName() string

AppName returns associated app name or code itself if app is not found.

func (Message) MemberMap

func (m Message) MemberMap(memberID interface{}) *MessageMap

MemberMap returns message map for the message and given member. This method will be called directly from template(index, show)

func (*Message) OwnedBy

func (m *Message) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (Message) Owner

func (m Message) Owner() *Member

Owner returns associated member instance (owner of the message)

func (Message) PriorityString

func (m Message) PriorityString() string

PriorityString returns human readable string of the message's priority

func (*Message) QueryParams

func (m *Message) QueryParams() QueryParams

QueryParams implements Belonging interface

func (Message) String

func (m Message) String() string

String returns representation of Messages

func (*Message) Validate

func (m *Message) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate" method.

type MessageMap

type MessageMap struct {
	ID        uuid.UUID `json:"id" db:"id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
	MemberID  uuid.UUID `json:"member_id" db:"member_id"`
	MessageID uuid.UUID `json:"message_id" db:"message_id"`
	IsSent    bool      `json:"is_sent" db:"is_sent"`
	IsRead    bool      `json:"is_read" db:"is_read"`
	IsBCC     bool      `json:"is_bcc" db:"is_bcc"`
}

MessageMap is structure for connection messages and members

func (MessageMap) String

func (m MessageMap) String() string

String returns human readable string of model message map.

type MessageMaps

type MessageMaps []MessageMap

MessageMaps is an array of message map

type Messages

type Messages []Message

Messages is an array of Messages

func (*Messages) AccessibleBy

func (m *Messages) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (*Messages) OwnedBy

func (m *Messages) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (*Messages) QueryParams

func (m *Messages) QueryParams() QueryParams

QueryParams implements Belonging interface

type MessagingLog

type MessagingLog struct {
	ID        uuid.UUID `json:"id" db:"id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
	Status    string    `json:"status" db:"status"`
	QueueID   string    `json:"queue_id" db:"queue_id"`
	Response  string    `json:"response" db:"response"`
	Method    string    `json:"method" db:"method"`
	SentFor   string    `json:"sent_for" db:"sent_for"`
	SentTo    string    `json:"sent_to" db:"sent_to"`
	Subject   string    `json:"subject" db:"subject"`
	Notes     string    `json:"notes" db:"notes"`
}

MessagingLog is a structure for log of messaging.

func (MessagingLog) String

func (m MessagingLog) String() string

String returns representation of the log

type MessagingLogs

type MessagingLogs []MessagingLog

MessagingLogs is an array of Messages

type Messenger

type Messenger struct {
	ID        uuid.UUID `json:"id" db:"id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
	MemberID  uuid.UUID `json:"member_id" db:"member_id"`
	Priority  int       `json:"priority" db:"priority"`
	Method    string    `json:"method" db:"method"`
	Value     string    `json:"value" db:"value"`
	IsPrimary bool      `json:"is_primary" db:"is_primary"`
}

Messenger is a structure for messaging methods

func (*Messenger) AccessibleBy

func (m *Messenger) AccessibleBy(q *pop.Query, o Owner, f ...bool) *pop.Query

AccessibleBy implements Belonging interface

func (*Messenger) OwnedBy

func (m *Messenger) OwnedBy(q *pop.Query, o Owner, f ...bool) *pop.Query

OwnedBy implements Belonging interface

func (*Messenger) QueryParams

func (m *Messenger) QueryParams() QueryParams

QueryParams implements Belonging interface

func (Messenger) String

func (m Messenger) String() string

String returns json marshalled representation of messenger

func (*Messenger) Validate

func (m *Messenger) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate" method.

func (*Messenger) ValidateSave

func (m *Messenger) ValidateSave(tx *pop.Connection) (*validate.Errors, error)

ValidateSave gets run every time you call "pop.ValidateSave" method.

func (*Messenger) ValidateUpdate

func (m *Messenger) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateUpdate" method.

type Messengers

type Messengers []Messenger

Messengers is an array of Messengers

type Object

type Object interface {
}

Object Interface (for general models)

type Owner

type Owner interface {
	GetID() interface{}
}

Owner is an interface for model which have belongings

type QueryParams

type QueryParams struct {
	DefaultSort string
	Sort        string

	FilterKey   string
	FilterValue interface{}
}

QueryParams is structure contains query parameters

type Role

type Role struct {
	ID          uuid.UUID `json:"id" db:"id"`
	CreatedAt   time.Time `json:"created_at" db:"created_at"`
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at"`
	AppID       uuid.UUID `json:"app_id" db:"app_id"`
	Name        string    `json:"name" db:"name"`
	Code        string    `json:"code" db:"code"`
	Description string    `json:"description" db:"description"`
	Rank        int       `json:"rank" db:"rank"`
	IsReadonly  bool      `json:"is_readonly" db:"is_readonly"`
}

Role is used to set member's privilege for each apps.

func GetAppRole

func GetAppRole(appCode, roleCode string) *Role

GetAppRole returns role instance found by given app code and role code.

func (Role) App

func (r Role) App() *App

App returns an app instance of the role

func (Role) MemberCount

func (r Role) MemberCount(isActive bool) int

MemberCount returns count of members who has the role

func (Role) Members

func (r Role) Members(flag ...bool) *Members

Members returns members have the role. if optional flag is true, only active members are returned.

func (Role) String

func (r Role) String() string

String returns pretty printable string of this model.

func (*Role) Validate

func (r *Role) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate" method.

func (*Role) ValidateSave

func (r *Role) ValidateSave(tx *pop.Connection) (*validate.Errors, error)

ValidateSave gets run every time you call "pop.ValidateSave" method.

func (*Role) ValidateUpdate

func (r *Role) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateUpdate" method.

type RoleMap

type RoleMap struct {
	ID        int       `json:"id" db:"id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
	RoleID    uuid.UUID `json:"role_id" db:"role_id"`
	MemberID  uuid.UUID `json:"member_id" db:"member_id"`
	IsActive  bool      `json:"is_active" db:"is_active"`
}

RoleMap is a mapping object for role and member.

func (RoleMap) Member

func (rm RoleMap) Member() *Member

Member returns associated member instance of this map.

func (RoleMap) Role

func (rm RoleMap) Role() *Role

Role returns associated role instance of this map.

type Roles

type Roles []Role

Roles is array of Role.

Jump to

Keyboard shortcuts

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