Documentation ¶
Index ¶
- type ChatDocument
- type ChatRepository
- func (cr *ChatRepository) AddUserByChatID(ctx context.Context, chatID string, userId string) (*entity.Chat, error)
- func (cr *ChatRepository) Colletion() *driver.Collection
- func (cr *ChatRepository) Create(ctx context.Context, chat *entity.Chat) (string, error)
- func (cr *ChatRepository) Database() *driver.Database
- func (cr *ChatRepository) DeleteChatByID(ctx context.Context, chatID string) error
- func (cr *ChatRepository) GetChatByID(ctx context.Context, chatID string) (*entity.Chat, error)
- func (cr *ChatRepository) ListChatByUserID(ctx context.Context, userID string, limit int) ([]*entity.Chat, error)
- type MessageDocument
- type MessageRepository
- func (mr *MessageRepository) Create(ctx context.Context, message *entity.Message) error
- func (mr *MessageRepository) DeleteAllMessageByChatID(ctx context.Context, chatID string) error
- func (mr *MessageRepository) ListMessageByChatID(ctx context.Context, chatID string, limit int) ([]*entity.Message, error)
- type UserDocument
- type UserRepository
- func (ur *UserRepository) Collection() driver.Collection
- func (ur *UserRepository) Create(ctx context.Context, user *entity.User) (string, error)
- func (ur *UserRepository) Database() *driver.Database
- func (ur *UserRepository) DeleteUserByID(ctx context.Context, id string) error
- func (ur *UserRepository) GetUserByEmail(ctx context.Context, email string) (*entity.User, error)
- func (ur *UserRepository) GetUserByID(ctx context.Context, id string) (*entity.User, error)
- func (ur *UserRepository) ListAll(ctx context.Context, limit int) ([]*entity.User, error)
- func (ur *UserRepository) UpdateUserByID(ctx context.Context, id string, user *entity.User) (*entity.User, error)
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 (*ChatRepository) Colletion ¶
func (cr *ChatRepository) Colletion() *driver.Collection
Colletion returns the collection instance of the UserRepository.
No parameters. Returns *driver.Collection.
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 (*ChatRepository) ListChatByUserID ¶
type MessageDocument ¶
type MessageRepository ¶
type MessageRepository struct {
// contains filtered or unexported fields
}
func NewMessageRepository ¶
func NewMessageRepository(db *arangodb.DB, collectionName string) *MessageRepository
func (*MessageRepository) Create ¶
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 ¶
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 ¶
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.