db

package
v0.0.0-...-9a8b118 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorNotFound = "mongo: no documents in result"
)

Variables

This section is empty.

Functions

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if the error is a not found error.

Types

type Chat

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

Chat is a collection of chats.

func (*Chat) GetByChatId

func (c *Chat) GetByChatId(chatId int64) (*models.Chat, error)

GetByChatId gets a message by chat id.

func (*Chat) Insert

func (c *Chat) Insert(chatId int64, user models.User) error

Insert inserts a chat into the database.

func (*Chat) SetChatGPTToken

func (c *Chat) SetChatGPTToken(chatId int64, chatGPTToken string) error

SetChatGPTToken sets the chat GPT token.

func (*Chat) UpdateLanguage

func (c *Chat) UpdateLanguage(chatId int64, language models.Language) error

UpdateLanguage updates the language of a chat.

func (*Chat) UpdateMode

func (c *Chat) UpdateMode(chatId int64, mode models.Mode) error

UpdateMode updates the mode of a chat.

type Message

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

Message is a collection of messages.

func (*Message) Archive

func (c *Message) Archive(chatId int64) error

Archive archives all messages by chat id.

func (*Message) GetLastMessages

func (c *Message) GetLastMessages(chatId int64, count int) ([]models.Message, error)

GetLastMessages gets the last messages by chat id.

func (*Message) Insert

func (c *Message) Insert(messageId int64, chatId int64, from int64, text string, timestamp int) error

Insert inserts a message into the database.

type MongoDB

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

MongoDB is a MongoDB database.

func NewMongoDB

func NewMongoDB() (*MongoDB, error)

NewMongoDB creates a new MongoDB instance.

func (*MongoDB) ChatCollection

func (db *MongoDB) ChatCollection() *Chat

ChatCollection is a collection of chats.

func (*MongoDB) MessageCollection

func (db *MongoDB) MessageCollection() *Message

MessageCollection is a collection of messages.

Jump to

Keyboard shortcuts

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