models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package models describes models for database communication.

Index

Constants

This section is empty.

Variables

View Source
var EmptyUsersBatch = UsersBatch{
	Users:     nil,
	Type:      UsersBatchTypeUnknown,
	CreatedAt: time.Time{},
}

EmptyUsersBatch represents nil batch.

View Source
var ErrInvalidUsersBatchType = errors.New("invalid users batch type")

ErrInvalidUsersBatchType means that batch type not supported.

Functions

func MakeInvalidBatchTypeError

func MakeInvalidBatchTypeError(t UsersBatchType) error

MakeInvalidBatchTypeError returns ErrInvalidUsersBatchType with added bathtype info.

Types

type Limits

type Limits struct {
	Follow   int
	UnFollow int
}

Limits represents action limits.

type User

type User struct {
	ID       int64  `bson:"id"`
	UserName string `bson:"user_name"`
	FullName string `bson:"full_name"`
}

User stores information about user.

func MakeUser

func MakeUser(id int64, username, fullname string) User

MakeUser creates User with passed values.

type UsersBatch

type UsersBatch struct {
	Users     []User         `bson:"users"`
	Type      UsersBatchType `bson:"batch_type"`
	CreatedAt time.Time      `bson:"created_at"`
}

UsersBatch represents info about specific type of users (followers, followings).

type UsersBatchType

type UsersBatchType int

UsersBatchType marks what is the type of users stored in the batch.

const (
	// UsersBatchTypeUnknown is unknown type, to cover default value case.
	UsersBatchTypeUnknown UsersBatchType = iota

	// UsersBatchTypeFollowers represents user's followers.
	UsersBatchTypeFollowers
	// UsersBatchTypeFollowings represents user's followings.
	UsersBatchTypeFollowings
	// UsersBatchTypeNotMutual represents users that not following back.
	UsersBatchTypeNotMutual
	// UsersBatchTypeBusinessAccounts represents business accounts.
	UsersBatchTypeBusinessAccounts
	// UsersBatchTypeLostFollowers represents lost followers.
	UsersBatchTypeLostFollowers
	// UsersBatchTypeNewFollowers represents new followers.
	UsersBatchTypeNewFollowers
)

func (UsersBatchType) String

func (i UsersBatchType) String() string

func (UsersBatchType) Valid

func (i UsersBatchType) Valid() bool

Valid checks if value is valid type.

Jump to

Keyboard shortcuts

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