db

package
v0.0.0-...-d808fcf Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

type Basic struct {
	ID        bson.ObjectId `bson:"_id,omitempty"`
	CreatedAt time.Time     `bson:"created_at"`
	UpdatedAt time.Time     `bson:"updated_at"`
	Deleted   bool          `bson:"deleted"`
}

Basic holds basic info for db record

func (*Basic) PrepareDelete

func (b *Basic) PrepareDelete()

PrepareDelete updates delete info

func (*Basic) PreparePut

func (b *Basic) PreparePut()

PreparePut prepares Basic before database put operation

type Conversation

type Conversation struct {
	Basic             `bson:",inline"`
	ClientID          string   `bson:"ClientID"`
	ConversationName  string   `bson:"ConversationName"`
	ConversationAdmin string   `bson:"ConversationAdmin"`
	Members           []Member `bson:"Members"`
}

Conversation holds conversation basic info

type Member

type Member struct {
	MemberID string `bson:"MemberID"`
	NickName string `bson:"NickName"`
	Role     string `bson:"Role"`

	JoinedBy    string    `bson:"JoinedBy"`
	JoiningTime time.Time `bson:"JoiningTime"`

	RemovedBy    string    `bson:"RemovedBy,omitempty"`
	RemovingTime time.Time `bson:"RemovingTime,omitempty"`

	LeavingTime time.Time `bson:"LeavingTime,omitempty"`
}

Member holds conversation member info

type Role

type Role struct {
	Basic              `bson:",inline"`
	Name               string         `bson:"name"`
	RoleAccess         app.AccessList `bson:"role_access"`
	UserAccess         app.AccessList `bson:"user_access"`
	CredentialAccess   app.AccessList `bson:"credential_access"`
	ConversationAccess app.AccessList `bson:"conversation_access"`
}

Role holds role data

func AdminRole

func AdminRole() Role

AdminRole returns role with super access

func (Role) Valid

func (r Role) Valid() error

Valid returns errors for invalid role data

type User

type User struct {
	Basic       `bson:",inline"`
	UserName    string        `bson:"user_name,omitempty"`
	Name        string        `bson:"name,omitempty"`
	Password    string        `bson:"password,omitempty"`
	RoleID      bson.ObjectId `bson:"role_id,omitempty"`
	Email       string        `bson:"email,omitempty"`
	Verified    bool          `bson:"verified,omitempty"`
	Phone       string        `bson:"phone,omitempty"`
	Address     []string      `bson:"address,omitempty"`
	DateOfBirth time.Time     `bson:"data_of_birth,omitempty"`
	Gender      string        `bson:"gender,omitempty"`
}

User holds User data

func AdminUser

func AdminUser(roleID bson.ObjectId) (User, error)

AdminUser returns admin user

func (User) Valid

func (u User) Valid() error

Valid returns errors for invalid admin data

Jump to

Keyboard shortcuts

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