database

package
v3.8.1-rc.4 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	BlackName               = "black"
	ConversationName        = "conversation"
	FriendName              = "friend"
	FriendVersionName       = "friend_version"
	FriendRequestName       = "friend_request"
	GroupName               = "group"
	GroupMemberName         = "group_member"
	GroupMemberVersionName  = "group_member_version"
	GroupJoinVersionName    = "group_join_version"
	ConversationVersionName = "conversation_version"
	GroupRequestName        = "group_request"
	LogName                 = "log"
	ObjectName              = "s3"
	UserName                = "user"
	SeqConversationName     = "seq"
	SeqUserName             = "seq_user"
)
View Source
const (
	FirstVersion         = 1
	DefaultDeleteVersion = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Black

type Black interface {
	Create(ctx context.Context, blacks []*model.Black) (err error)
	Delete(ctx context.Context, blacks []*model.Black) (err error)
	Find(ctx context.Context, blacks []*model.Black) (blackList []*model.Black, err error)
	Take(ctx context.Context, ownerUserID, blockUserID string) (black *model.Black, err error)
	FindOwnerBlacks(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (total int64, blacks []*model.Black, err error)
	FindOwnerBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*model.Black, err error)
	FindBlackUserIDs(ctx context.Context, ownerUserID string) (blackUserIDs []string, err error)
}

type Conversation

type Conversation interface {
	Create(ctx context.Context, conversations []*model.Conversation) (err error)
	UpdateByMap(ctx context.Context, userIDs []string, conversationID string, args map[string]any) (rows int64, err error)
	Update(ctx context.Context, conversation *model.Conversation) (err error)
	Find(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []*model.Conversation, err error)
	FindUserID(ctx context.Context, userIDs []string, conversationIDs []string) ([]string, error)
	FindUserIDAllConversationID(ctx context.Context, userID string) ([]string, error)
	FindUserIDAllNotNotifyConversationID(ctx context.Context, userID string) ([]string, error)
	FindUserIDAllPinnedConversationID(ctx context.Context, userID string) ([]string, error)
	Take(ctx context.Context, userID, conversationID string) (conversation *model.Conversation, err error)
	FindConversationID(ctx context.Context, userID string, conversationIDs []string) (existConversationID []string, err error)
	FindUserIDAllConversations(ctx context.Context, userID string) (conversations []*model.Conversation, err error)
	FindRecvMsgUserIDs(ctx context.Context, conversationID string, recvOpts []int) ([]string, error)
	GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)
	GetAllConversationIDs(ctx context.Context) ([]string, error)
	GetAllConversationIDsNumber(ctx context.Context) (int64, error)
	PageConversationIDs(ctx context.Context, pagination pagination.Pagination) (conversationIDs []string, err error)
	GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*model.Conversation, error)
	GetConversationIDsNeedDestruct(ctx context.Context) ([]*model.Conversation, error)
	GetConversationNotReceiveMessageUserIDs(ctx context.Context, conversationID string) ([]string, error)
	FindConversationUserVersion(ctx context.Context, userID string, version uint, limit int) (*model.VersionLog, error)
}

type Friend

type Friend interface {
	// Create inserts multiple friend records.
	Create(ctx context.Context, friends []*model.Friend) (err error)
	// Delete removes specified friends of the owner user.
	Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error)
	// UpdateByMap updates specific fields of a friend document using a map.
	UpdateByMap(ctx context.Context, ownerUserID string, friendUserID string, args map[string]any) (err error)
	// UpdateRemark modify remarks.
	UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
	// Take retrieves a single friend document. Returns an error if not found.
	Take(ctx context.Context, ownerUserID, friendUserID string) (friend *model.Friend, err error)
	// FindUserState finds the friendship status between two users.
	FindUserState(ctx context.Context, userID1, userID2 string) (friends []*model.Friend, err error)
	// FindFriends retrieves a list of friends for a given owner. Missing friends do not cause an error.
	FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*model.Friend, err error)
	// FindReversalFriends finds users who have added the specified user as a friend.
	FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string) (friends []*model.Friend, err error)
	// FindOwnerFriends retrieves a paginated list of friends for a given owner.
	FindOwnerFriends(ctx context.Context, ownerUserID string, pagination pagination.Pagination) (total int64, friends []*model.Friend, err error)
	// FindInWhoseFriends finds users who have added the specified user as a friend, with pagination.
	FindInWhoseFriends(ctx context.Context, friendUserID string, pagination pagination.Pagination) (total int64, friends []*model.Friend, err error)
	// FindFriendUserIDs retrieves a list of friend user IDs for a given owner.
	FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error)
	// UpdateFriends update friends' fields
	UpdateFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, val map[string]any) (err error)

	FindIncrVersion(ctx context.Context, ownerUserID string, version uint, limit int) (*model.VersionLog, error)

	FindFriendUserID(ctx context.Context, friendUserID string) ([]string, error)

	FindOwnerFriendUserIds(ctx context.Context, ownerUserID string, limit int) ([]string, error)

	IncrVersion(ctx context.Context, ownerUserID string, friendUserIDs []string, state int32) error
}

Friend defines the operations for managing friends in MongoDB.

type FriendRequest

type FriendRequest interface {
	// Insert multiple records
	Create(ctx context.Context, friendRequests []*model.FriendRequest) (err error)
	// Delete record
	Delete(ctx context.Context, fromUserID, toUserID string) (err error)
	// Update with zero values
	UpdateByMap(ctx context.Context, formUserID string, toUserID string, args map[string]any) (err error)
	// Update multiple records (non-zero values)
	Update(ctx context.Context, friendRequest *model.FriendRequest) (err error)
	// Get friend requests sent to a specific user, no error returned if not found
	Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *model.FriendRequest, err error)
	Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *model.FriendRequest, err error)
	// Get list of friend requests received by toUserID
	FindToUserID(ctx context.Context, toUserID string, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error)
	// Get list of friend requests sent by fromUserID
	FindFromUserID(ctx context.Context, fromUserID string, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error)
	FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*model.FriendRequest, err error)
}

type Group

type Group interface {
	Create(ctx context.Context, groups []*model.Group) (err error)
	UpdateMap(ctx context.Context, groupID string, args map[string]any) (err error)
	UpdateStatus(ctx context.Context, groupID string, status int32) (err error)
	Find(ctx context.Context, groupIDs []string) (groups []*model.Group, err error)
	Take(ctx context.Context, groupID string) (group *model.Group, err error)
	Search(ctx context.Context, keyword string, pagination pagination.Pagination) (total int64, groups []*model.Group, err error)
	// Get Group total quantity
	CountTotal(ctx context.Context, before *time.Time) (count int64, err error)
	// Get Group total quantity every day
	CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)

	FindJoinSortGroupID(ctx context.Context, groupIDs []string) ([]string, error)

	SearchJoin(ctx context.Context, groupIDs []string, keyword string, pagination pagination.Pagination) (int64, []*model.Group, error)
}

type GroupMember

type GroupMember interface {
	Create(ctx context.Context, groupMembers []*model.GroupMember) (err error)
	Delete(ctx context.Context, groupID string, userIDs []string) (err error)
	Update(ctx context.Context, groupID string, userID string, data map[string]any) (err error)
	UpdateRoleLevel(ctx context.Context, groupID string, userID string, roleLevel int32) error
	UpdateUserRoleLevels(ctx context.Context, groupID string, firstUserID string, firstUserRoleLevel int32, secondUserID string, secondUserRoleLevel int32) error
	FindMemberUserID(ctx context.Context, groupID string) (userIDs []string, err error)
	Take(ctx context.Context, groupID string, userID string) (groupMember *model.GroupMember, err error)
	Find(ctx context.Context, groupID string, userIDs []string) ([]*model.GroupMember, error)
	FindInGroup(ctx context.Context, userID string, groupIDs []string) ([]*model.GroupMember, error)
	TakeOwner(ctx context.Context, groupID string) (groupMember *model.GroupMember, err error)
	SearchMember(ctx context.Context, keyword string, groupID string, pagination pagination.Pagination) (total int64, groupList []*model.GroupMember, err error)
	FindRoleLevelUserIDs(ctx context.Context, groupID string, roleLevel int32) ([]string, error)
	FindUserJoinedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
	TakeGroupMemberNum(ctx context.Context, groupID string) (count int64, err error)
	FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
	IsUpdateRoleLevel(data map[string]any) bool
	JoinGroupIncrVersion(ctx context.Context, userID string, groupIDs []string, state int32) error
	MemberGroupIncrVersion(ctx context.Context, groupID string, userIDs []string, state int32) error
	FindMemberIncrVersion(ctx context.Context, groupID string, version uint, limit int) (*model.VersionLog, error)
	BatchFindMemberIncrVersion(ctx context.Context, groupIDs []string, versions []uint, limits []int) ([]*model.VersionLog, error)
	FindJoinIncrVersion(ctx context.Context, userID string, version uint, limit int) (*model.VersionLog, error)
}

type GroupRequest

type GroupRequest interface {
	Create(ctx context.Context, groupRequests []*model.GroupRequest) (err error)
	Delete(ctx context.Context, groupID string, userID string) (err error)
	UpdateHandler(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32) (err error)
	Take(ctx context.Context, groupID string, userID string) (groupRequest *model.GroupRequest, err error)
	FindGroupRequests(ctx context.Context, groupID string, userIDs []string) ([]*model.GroupRequest, error)
	Page(ctx context.Context, userID string, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error)
	PageGroup(ctx context.Context, groupIDs []string, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error)
}

type Log

type Log interface {
	Create(ctx context.Context, log []*model.Log) error
	Search(ctx context.Context, keyword string, start time.Time, end time.Time, pagination pagination.Pagination) (int64, []*model.Log, error)
	Delete(ctx context.Context, logID []string, userID string) error
	Get(ctx context.Context, logIDs []string, userID string) ([]*model.Log, error)
}

type Msg

type Msg interface {
	PushMsgsToDoc(ctx context.Context, docID string, msgsToMongo []model.MsgInfoModel) error
	Create(ctx context.Context, model *model.MsgDocModel) error
	UpdateMsg(ctx context.Context, docID string, index int64, key string, value any) (*mongo.UpdateResult, error)
	PushUnique(ctx context.Context, docID string, index int64, key string, value any) (*mongo.UpdateResult, error)
	UpdateMsgContent(ctx context.Context, docID string, index int64, msg []byte) error
	IsExistDocID(ctx context.Context, docID string) (bool, error)
	FindOneByDocID(ctx context.Context, docID string) (*model.MsgDocModel, error)
	GetMsgBySeqIndexIn1Doc(ctx context.Context, userID, docID string, seqs []int64) ([]*model.MsgInfoModel, error)
	GetNewestMsg(ctx context.Context, conversationID string) (*model.MsgInfoModel, error)
	GetOldestMsg(ctx context.Context, conversationID string) (*model.MsgInfoModel, error)
	DeleteDocs(ctx context.Context, docIDs []string) error
	GetMsgDocModelByIndex(ctx context.Context, conversationID string, index, sort int64) (*model.MsgDocModel, error)
	DeleteMsgsInOneDocByIndex(ctx context.Context, docID string, indexes []int) error
	MarkSingleChatMsgsAsRead(ctx context.Context, userID string, docID string, indexes []int64) error
	SearchMessage(ctx context.Context, req *msg.SearchMessageReq) (int64, []*model.MsgInfoModel, error)
	RangeUserSendCount(ctx context.Context, start time.Time, end time.Time, group bool, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, users []*model.UserCount, dateCount map[string]int64, err error)
	RangeGroupSendCount(ctx context.Context, start time.Time, end time.Time, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, groups []*model.GroupCount, dateCount map[string]int64, err error)
	ConvertMsgsDocLen(ctx context.Context, conversationIDs []string)

	DeleteDoc(ctx context.Context, docID string) error
	DeleteMsgByIndex(ctx context.Context, docID string, index []int) error
	GetBeforeMsg(ctx context.Context, ts int64, docIDs []string, limit int) ([]*model.MsgDocModel, error)

	GetDocIDs(ctx context.Context) ([]string, error)
}

type ObjectInfo

type ObjectInfo interface {
	SetObject(ctx context.Context, obj *model.Object) error
	Take(ctx context.Context, engine string, name string) (*model.Object, error)
	Delete(ctx context.Context, engine string, name string) error
	FindByExpires(ctx context.Context, duration time.Time, pagination pagination.Pagination) (total int64, objects []*model.Object, err error)
	FindNotDelByS3(ctx context.Context, key string, duration time.Time) (int64, error)
}

type SeqConversation

type SeqConversation interface {
	Malloc(ctx context.Context, conversationID string, size int64) (int64, error)
	GetMaxSeq(ctx context.Context, conversationID string) (int64, error)
	SetMaxSeq(ctx context.Context, conversationID string, seq int64) error
	GetMinSeq(ctx context.Context, conversationID string) (int64, error)
	SetMinSeq(ctx context.Context, conversationID string, seq int64) error
}

type SeqTime added in v3.8.1

type SeqTime struct {
	Seq  int64
	Time int64
}

type SeqUser

type SeqUser interface {
	GetUserMaxSeq(ctx context.Context, conversationID string, userID string) (int64, error)
	SetUserMaxSeq(ctx context.Context, conversationID string, userID string, seq int64) error
	GetUserMinSeq(ctx context.Context, conversationID string, userID string) (int64, error)
	SetUserMinSeq(ctx context.Context, conversationID string, userID string, seq int64) error
	GetUserReadSeq(ctx context.Context, conversationID string, userID string) (int64, error)
	SetUserReadSeq(ctx context.Context, conversationID string, userID string, seq int64) error
	GetUserReadSeqs(ctx context.Context, userID string, conversationID []string) (map[string]int64, error)
}

type User

type User interface {
	Create(ctx context.Context, users []*model.User) (err error)
	UpdateByMap(ctx context.Context, userID string, args map[string]any) (err error)
	Find(ctx context.Context, userIDs []string) (users []*model.User, err error)
	Take(ctx context.Context, userID string) (user *model.User, err error)
	TakeNotification(ctx context.Context, level int64) (user []*model.User, err error)
	TakeByNickname(ctx context.Context, nickname string) (user []*model.User, err error)
	Page(ctx context.Context, pagination pagination.Pagination) (count int64, users []*model.User, err error)
	PageFindUser(ctx context.Context, level1 int64, level2 int64, pagination pagination.Pagination) (count int64, users []*model.User, err error)
	PageFindUserWithKeyword(ctx context.Context, level1 int64, level2 int64, userID, nickName string, pagination pagination.Pagination) (count int64, users []*model.User, err error)
	Exist(ctx context.Context, userID string) (exist bool, err error)
	GetAllUserID(ctx context.Context, pagination pagination.Pagination) (count int64, userIDs []string, err error)
	GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)
	// Get user total quantity
	CountTotal(ctx context.Context, before *time.Time) (count int64, err error)
	// Get user total quantity every day
	CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)

	SortQuery(ctx context.Context, userIDName map[string]string, asc bool) ([]*model.User, error)

	// CRUD user command
	AddUserCommand(ctx context.Context, userID string, Type int32, UUID string, value string, ex string) error
	DeleteUserCommand(ctx context.Context, userID string, Type int32, UUID string) error
	UpdateUserCommand(ctx context.Context, userID string, Type int32, UUID string, val map[string]any) error
	GetUserCommand(ctx context.Context, userID string, Type int32) ([]*user.CommandInfoResp, error)
	GetAllUserCommand(ctx context.Context, userID string) ([]*user.AllCommandInfoResp, error)
}

type VersionLog

type VersionLog interface {
	IncrVersion(ctx context.Context, dId string, eIds []string, state int32) error
	FindChangeLog(ctx context.Context, dId string, version uint, limit int) (*model.VersionLog, error)
	BatchFindChangeLog(ctx context.Context, dIds []string, versions []uint, limits []int) ([]*model.VersionLog, error)
	DeleteAfterUnchangedLog(ctx context.Context, deadline time.Time) error
	Delete(ctx context.Context, dId string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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