storage

package
v0.0.0-...-4c96ec7 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBotStateNotFound - bot state is not found.
	ErrBotStateNotFound = errors.New("bot state is not found")
	// ErrBotStateAlreadyExists - bot state is already exists.
	ErrBotStateAlreadyExists = errors.New("bot state already exists")
)
View Source
var (
	// ErrUserAlreadyExists - user is already exist.
	ErrUserAlreadyExists = errors.New("user already exists")
	// ErrUserNotFound - user is not found.
	ErrUserNotFound = errors.New("user is not found")
)
View Source
var ErrReminderNotFound = errors.New("reminder is not found")

ErrReminderNotFound - reminder is not found

Functions

This section is empty.

Types

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage - storage.

func NewSqllite

func NewSqllite(file, migrationsDir string) (*Storage, error)

NewSqllite creates a new sqlite Storage.

func (*Storage) DelayReminder

func (s *Storage) DelayReminder(ctx context.Context, id int64, remindAt time.Time) error

DelayReminder - delays reminder by id. Reminder will be fired at remindAt time.

func (*Storage) GetBotState

func (s *Storage) GetBotState(ctx context.Context, userID int64) (domain.BotState, error)

GetBotState - returns bot state by user id.

func (*Storage) GetMyReminders

func (s *Storage) GetMyReminders(ctx context.Context, userID, chatID int64) ([]domain.Reminder, error)

GetMyReminders - returns reminders by user id and chat id.

func (*Storage) GetPendingReminders

func (s *Storage) GetPendingReminders(ctx context.Context, limit int64) ([]domain.Reminder, error)

GetPendingReminders - returns reminders in domain.ReminderStatusPending status for active users.

func (*Storage) RemoveReminder

func (s *Storage) RemoveReminder(ctx context.Context, id int64) error

RemoveReminder - removes reminder by id.

func (*Storage) SaveBotState

func (s *Storage) SaveBotState(ctx context.Context, state domain.BotState) error

SaveBotState - saves bot state.

func (*Storage) SaveReminder

func (s *Storage) SaveReminder(ctx context.Context, reminder domain.Reminder) (int64, error)

SaveReminder - saves reminder.

func (*Storage) SaveUser

func (s *Storage) SaveUser(ctx context.Context, user domain.User) error

SaveUser - saves user.

func (*Storage) SetReminderStatus

func (s *Storage) SetReminderStatus(ctx context.Context, id int64, status domain.ReminderStatus) error

SetReminderStatus - set's reminder status by id.

func (*Storage) SetUserStatus

func (s *Storage) SetUserStatus(ctx context.Context, id int64, status domain.UserStatus) error

SetUserStatus - set's user status by user id.

func (*Storage) UpdateReminder

func (s *Storage) UpdateReminder(ctx context.Context, reminder domain.Reminder) error

UpdateReminder - updates reminder.

Jump to

Keyboard shortcuts

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