repository

package
v0.0.0-...-10a342f Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatDocument

type ChatDocument struct {
	Key      string   `json:"_key"`
	Id       string   `json:"id"`
	FromUser string   `json:"fromUser"`
	ToUsers  []string `json:"toUsers"`
}

func NewChatDocument

func NewChatDocument(chat *entity.Chat) *ChatDocument

type ChatRepository

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

func NewChatRepository

func NewChatRepository(db *arangodb.DB, collectionName string) *ChatRepository

func (*ChatRepository) AddUserByChatID

func (cr *ChatRepository) AddUserByChatID(ctx context.Context, chatID string, userId string) (*entity.Chat, error)

func (*ChatRepository) Colletion

func (cr *ChatRepository) Colletion() *driver.Collection

Colletion returns the collection instance of the UserRepository.

No parameters. Returns *driver.Collection.

func (*ChatRepository) Create

func (cr *ChatRepository) Create(ctx context.Context, chat *entity.Chat) (string, error)

func (*ChatRepository) Database

func (cr *ChatRepository) Database() *driver.Database

Database returns the database instance of the UserRepository.

No parameters. Returns a pointer to the driver.Database.

func (*ChatRepository) DeleteChatByID

func (cr *ChatRepository) DeleteChatByID(ctx context.Context, chatID string) error

func (*ChatRepository) GetChatByID

func (cr *ChatRepository) GetChatByID(ctx context.Context, chatID string) (*entity.Chat, error)

func (*ChatRepository) ListChatByUserID

func (cr *ChatRepository) ListChatByUserID(ctx context.Context, userID string, limit int) ([]*entity.Chat, error)

type MessageDocument

type MessageDocument struct {
	ChatID  string
	Content string
	File    []byte
	Created string
}

type MessageRepository

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

func NewMessageRepository

func NewMessageRepository(db *arangodb.DB, collectionName string) *MessageRepository

func (*MessageRepository) Create

func (mr *MessageRepository) Create(ctx context.Context, message *entity.Message) error

Create saves a message to the database.

It takes a context and a message as parameters. It returns an error if the message fails to be created.

func (*MessageRepository) DeleteAllMessageByChatID

func (mr *MessageRepository) DeleteAllMessageByChatID(ctx context.Context, chatID string) error

DeleteAllMessageByChatID deletes all messages in the message repository that belong to a specific chat ID.

ctx: the context object for the function chatID: the ID of the chat error: an error if the deletion fails Returns: an error if the deletion fails

func (*MessageRepository) ListMessageByChatID

func (mr *MessageRepository) ListMessageByChatID(ctx context.Context, chatID string, limit int) ([]*entity.Message, error)

ListMessageByChatID retrieves a list of messages by chat ID.

ctx: the context.Context object for managing the lifetime of the operation. chatID: the chat ID for which the messages should be retrieved. limit: the maximum number of messages to retrieve. []*entity.Message: a slice of entity.Message pointers representing the retrieved messages. error: an error if the operation fails.

type UserDocument

type UserDocument struct {
	Key       string `json:"_key"`
	Id        string `json:"id"`
	Email     string `json:"email"`
	Name      string `json:"name"`
	Bio       string `json:"bio"`
	Avatar    []byte `json:"avatar"`
	CreatedAt string `json:"createdAt"`
	UpdatedAt string `json:"updatedAt"`
}

func NewUserDocument

func NewUserDocument(user *entity.User) *UserDocument

type UserRepository

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

func NewUserRepository

func NewUserRepository(db *arangodb.DB, collectionName string) *UserRepository

func (*UserRepository) Collection

func (ur *UserRepository) Collection() driver.Collection

Colletion returns the collection instance of the UserRepository.

No parameters. Returns *driver.Collection.

func (*UserRepository) Create

func (ur *UserRepository) Create(ctx context.Context, user *entity.User) (string, error)

Create creates a new user in the database.

ctx - The context object. user - The user object to be created. Returns the key of the created user and an error, if any.

func (*UserRepository) Database

func (ur *UserRepository) Database() *driver.Database

Database returns the database instance of the UserRepository.

No parameters. Returns a pointer to the driver.Database.

func (*UserRepository) DeleteUserByID

func (ur *UserRepository) DeleteUserByID(ctx context.Context, id string) error

func (*UserRepository) GetUserByEmail

func (ur *UserRepository) GetUserByEmail(ctx context.Context, email string) (*entity.User, error)

GetUserByEmail retrieves a user from the UserRepository by their email.

ctx: The context for the function execution. email: The email of the user to retrieve. Returns a pointer to the User entity and an error, if any.

func (*UserRepository) GetUserByID

func (ur *UserRepository) GetUserByID(ctx context.Context, id string) (*entity.User, error)

func (*UserRepository) ListAll

func (ur *UserRepository) ListAll(ctx context.Context, limit int) ([]*entity.User, error)

ListAll retrieves all users from the UserRepository.

It takes two parameters: 1. ctx: the context.Context object for cancellation and timeout. 2. limit: the maximum number of users to retrieve.

It returns a slice of *entity.User and an error.

func (*UserRepository) UpdateUserByID

func (ur *UserRepository) UpdateUserByID(ctx context.Context, id string, user *entity.User) (*entity.User, error)

Jump to

Keyboard shortcuts

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