db

package
v0.0.0-...-0064678 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChatRepository

func NewChatRepository(db *mongo.Database) (*chatRepositoryImpl, error)

func NewChatRepositoryTest

func NewChatRepositoryTest(collection *mongo.Collection) (*chatRepositoryImpl, error)

NewUserRepositoryTest for Tests (bad)

func NewCommentRepository

func NewCommentRepository(db *mongo.Database) (*commentRepositoryImpl, error)

func NewCommentRepositoryTest

func NewCommentRepositoryTest(collection *mongo.Collection) (*commentRepositoryImpl, error)

NewUserRepositoryTest for Tests (bad)

func NewCommunityRepository

func NewCommunityRepository(db *mongo.Database) (*comunnityRepositoryImpl, error)

func NewCommunityRepositoryTest

func NewCommunityRepositoryTest(collection *mongo.Collection) (*comunnityRepositoryImpl, error)

NewCommunityRepositoryTest for Tests (bad)

func NewFriendsRepository

func NewFriendsRepository(db *mongo.Database) (*friendsRepositoryImpl, error)

func NewFriendsRepositoryTest

func NewFriendsRepositoryTest(collection *mongo.Collection) (*friendsRepositoryImpl, error)

func NewLikeRepository

func NewLikeRepository(db *mongo.Database) (*likeRepositoryImpl, error)

func NewLikeRepositoryTest

func NewLikeRepositoryTest(collection *mongo.Collection) (*likeRepositoryImpl, error)

NewLikeRepositoryTest for Tests (bad)

func NewPostRepository

func NewPostRepository(db *mongo.Database) (*postRepositoryImpl, error)

func NewPostRepositoryTest

func NewPostRepositoryTest(collection *mongo.Collection) (*postRepositoryImpl, error)

NewUserRepositoryTest for Tests (bad)

func NewUserRepository

func NewUserRepository(db *mongo.Database) (*userRepositoryImpl, error)

NewUserRepository creates a new instance of userRepositoryImpl

func NewUserRepositoryTest

func NewUserRepositoryTest(collection *mongo.Collection) (*userRepositoryImpl, error)

NewUserRepositoryTest for Tests (bad)

func TestComment

func TestComment(t *testing.T) *core.Comment

func TestCommentNull

func TestCommentNull(t *testing.T) *core.Comment

func TestCommunity

func TestCommunity(t *testing.T) *core.Community

func TestDialog

func TestDialog(t *testing.T) *core.Dialog

func TestDialogNull

func TestDialogNull(t *testing.T) *core.Dialog

func TestFriends

func TestFriends(t *testing.T) *core.Friends

func TestFriendsNull

func TestFriendsNull(t *testing.T) *core.Friends

func TestLike

func TestLike(t *testing.T) *core.Like

func TestMessage

func TestMessage(t *testing.T) *core.Message

func TestNullCommunity

func TestNullCommunity(t *testing.T) *core.Community

func TestNullLike

func TestNullLike(t *testing.T) *core.Like

func TestPost

func TestPost(t *testing.T) *core.Post

func TestPostNull

func TestPostNull(t *testing.T) *core.Post

func TestUser

func TestUser(t *testing.T) *core.User

func TestUserNull

func TestUserNull(t *testing.T) *core.User

Types

type ChatRepository

type ChatRepository interface {
	IsUniqDialog(ctx context.Context, userID1 string, userID2 string) error
	IsDialogExist(ctx context.Context, userID1 string, userID2 string) (string, error)
	CreateDialog(ctx context.Context, userID string, name string, authorIDs []string) (*core.Dialog, error)
	IsChatExist(ctx context.Context, dialogID string) error
	SendMessage(ctx context.Context, message core.Message, dialogID string) error
	ReadMessage(ctx context.Context, userID string, messageID string, dialogID string) error
	GetDialogByID(ctx context.Context, dialogID string) (*core.Dialog, error)
}

type CommentRepository

type CommentRepository interface {
	CreateComment(ctx context.Context, comment *core.Comment) (*core.Comment, error)
	GetCommentByID(ctx context.Context, commentID string) (*core.Comment, error)
	EditComment(ctx context.Context, comment *core.Comment) (*core.Comment, error)
	DeleteComment(ctx context.Context, commentID string) error
}

type CommunityRepository

type CommunityRepository interface {
	CreateCommunity(ctx context.Context, community *core.Community) (*core.Community, error)
	EditCommunity(ctx context.Context, community *core.Community) error
	GetCommunityByID(ctx context.Context, communityID string) (*core.Community, error)
	DeleteCommunity(ctx context.Context, communityID string) error

	SearchCommunities(ctx context.Context, selector string, limit, pageNumber int64) ([]core.Community, *common.PageResponse, error)
	GetAllCommunities(ctx context.Context, limit, pageNumber int64) ([]core.Community, *common.PageResponse, error)

	AddFollower(ctx context.Context, communityID string, userID string) error
	DeleteFollower(ctx context.Context, communityID string, userID string) error
	DeleteAdmin(ctx context.Context, communityID string, userID string) error

	CommunityAddPost(ctx context.Context, communityID string, postID string) error
	CommunityDeletePost(ctx context.Context, communityID string, postID string) error
}

type FriendsRepository

type FriendsRepository interface {
	CreateFriends(ctx context.Context, userID string) error
	IsUniqRequest(ctx context.Context, from string, to string) error
	IsNotFriend(ctx context.Context, from string, to string) error

	CreateRequest(ctx context.Context, from string, to string) error
	DeleteRequest(ctx context.Context, from string, to string) error

	MakeFriends(ctx context.Context, userID1 string, userID2 string) error
	DeleteFriend(ctx context.Context, userID1 string, userID2 string) error

	GetFriends(ctx context.Context, userID string) ([]string, error)
	GetIncomingRequests(ctx context.Context, userID string) ([]string, error)
	GetOutcomingRequests(ctx context.Context, userID string) ([]string, error)
}

type LikeRepository

type LikeRepository interface {
	CreateLike(ctx context.Context, like *core.Like) (*core.Like, error)
	DeleteLike(ctx context.Context, subjectID string) error
	GetLikeBySubjectID(ctx context.Context, subjectID string) (*core.Like, error)
	IncreaseLike(ctx context.Context, subjectID string, userID string) error
	ReduceLike(ctx context.Context, subjectID string, userID string) error
}

type PostRepository

type PostRepository interface {
	CreatePost(ctx context.Context, post *core.Post) (*core.Post, error)

	GetPostByID(ctx context.Context, postID string) (*core.Post, error)
	GetPostsByUserID(ctx context.Context, userID string, pageNumber int64, limit int64) ([]core.Post, *common.PageResponse, error)

	EditPost(ctx context.Context, post *core.Post) (*core.Post, error)
	DeletePost(ctx context.Context, postID string) error

	GetFeed(ctx context.Context, userID string, pageNumber int64, limit int64) ([]core.Post, *common.PageResponse, error)

	PostAddComment(ctx context.Context, postID string, commentID string) error
	PostCheckComment(ctx context.Context, post *core.Post, commentID string) error
	PostDeleteComment(ctx context.Context, postID string, commentID string) error
}

type Repository

type Repository struct {
	UserRepo      UserRepository
	FriendsRepo   FriendsRepository
	PostRepo      PostRepository
	ChatRepo      ChatRepository
	LikeRepo      LikeRepository
	CommunityRepo CommunityRepository
	CommentRepo   CommentRepository
}

func NewRepository

func NewRepository(dbConn *mongo.Database) (*Repository, error)

type UserRepository

type UserRepository interface {
	CreateUser(ctx context.Context, user *core.User) error
	InsertUser(ctx context.Context, user *core.User) error

	GetUserByID(ctx context.Context, ID string) (*core.User, error)
	GetUserByEmail(ctx context.Context, email string) (*core.User, error)

	CheckUserIDExistence(ctx context.Context, id string) (bool, error)
	CheckUserEmailExistence(ctx context.Context, email string) (bool, error)

	UpdateUser(ctx context.Context, user *core.User) error

	DeleteUser(ctx context.Context, user *core.User) error

	UserAddPost(ctx context.Context, userID string, postID string) error
	UserCheckPost(ctx context.Context, user *core.User, postID string) error
	UserDeletePost(ctx context.Context, userID string, postID string) error

	SelectUsers(ctx context.Context, selector string, pageNumber int64, limit int64) ([]*core.User, *common.PageResponse, error)

	AddDialog(ctx context.Context, dialogID string, userID string) error
	GetUserDialogs(ctx context.Context, userID string) ([]string, error)
	IsUserInDialog(ctx context.Context, userID string, dialogID string) (bool, error)
	UserCheckDialog(ctx context.Context, dialogID string, userID string) error

	UserAddCommunity(ctx context.Context, userID string, communityID string) error
	UserDeleteCommunity(ctx context.Context, userID string, communityID string) error
	UserCheckCommunity(ctx context.Context, userID string, communityID string) error
}

Jump to

Keyboard shortcuts

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