Documentation ¶
Index ¶
- Constants
- Variables
- func NewMsgMongoDriver(database *mongo.Database) table.MsgDocModelInterface
- func NewSuperGroupMongoDriver(database *mongo.Database) unrelation.SuperGroupModelInterface
- func NewUserMongoDriver(database *mongo.Database) unrelation.UserModelInterface
- type Mongo
- type MsgMongoDriver
- func (m *MsgMongoDriver) ConvertMsgsDocLen(ctx context.Context, conversationIDs []string)
- func (m *MsgMongoDriver) Create(ctx context.Context, model *table.MsgDocModel) error
- func (m *MsgMongoDriver) DeleteDocs(ctx context.Context, docIDs []string) error
- func (m *MsgMongoDriver) DeleteMsgsInOneDocByIndex(ctx context.Context, docID string, indexes []int) error
- func (m *MsgMongoDriver) FindOneByDocID(ctx context.Context, docID string) (*table.MsgDocModel, error)
- func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, userID string, docID string, seqs []int64) (msgs []*table.MsgInfoModel, err error)
- func (m *MsgMongoDriver) GetMsgDocModelByIndex(ctx context.Context, conversationID string, index, sort int64) (*table.MsgDocModel, error)
- func (m *MsgMongoDriver) GetNewestMsg(ctx context.Context, conversationID string) (*table.MsgInfoModel, error)
- func (m *MsgMongoDriver) GetOldestMsg(ctx context.Context, conversationID string) (*table.MsgInfoModel, error)
- func (m *MsgMongoDriver) IsExistDocID(ctx context.Context, docID string) (bool, error)
- func (m *MsgMongoDriver) MarkSingleChatMsgsAsRead(ctx context.Context, userID string, docID string, indexes []int64) error
- func (m *MsgMongoDriver) PushMsgsToDoc(ctx context.Context, docID string, msgsToMongo []table.MsgInfoModel) error
- func (m *MsgMongoDriver) PushUnique(ctx context.Context, docID string, index int64, key string, value any) (*mongo.UpdateResult, error)
- func (m *MsgMongoDriver) RangeGroupSendCount(ctx context.Context, start time.Time, end time.Time, ase bool, ...) (msgCount int64, userCount int64, groups []*table.GroupCount, ...)
- func (m *MsgMongoDriver) RangeUserSendCount(ctx context.Context, start time.Time, end time.Time, group bool, ase bool, ...) (msgCount int64, userCount int64, users []*table.UserCount, ...)
- func (m *MsgMongoDriver) SearchMessage(ctx context.Context, req *msg.SearchMessageReq) (int32, []*table.MsgInfoModel, error)
- func (m *MsgMongoDriver) UpdateMsg(ctx context.Context, docID string, index int64, key string, value any) (*mongo.UpdateResult, error)
- func (m *MsgMongoDriver) UpdateMsgContent(ctx context.Context, docID string, index int64, msg []byte) error
- func (m *MsgMongoDriver) UpdateMsgStatusByIndexInOneDoc(ctx context.Context, docID string, msg *sdkws.MsgData, seqIndex int, ...) error
- type SuperGroupMongoDriver
- func (s *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error
- func (s *SuperGroupMongoDriver) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string) error
- func (s *SuperGroupMongoDriver) DeleteSuperGroup(ctx context.Context, groupID string) error
- func (s *SuperGroupMongoDriver) FindSuperGroup(ctx context.Context, groupIDs []string) (groups []*unrelation.SuperGroupModel, err error)
- func (s *SuperGroupMongoDriver) GetSuperGroupByUserID(ctx context.Context, userID string) (*unrelation.UserToSuperGroupModel, error)
- func (s *SuperGroupMongoDriver) RemoveGroupFromUser(ctx context.Context, groupID string, userIDs []string) error
- func (s *SuperGroupMongoDriver) RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string) error
- func (s *SuperGroupMongoDriver) TakeSuperGroup(ctx context.Context, groupID string) (group *unrelation.SuperGroupModel, err error)
- type UserMongoDriver
- func (u *UserMongoDriver) AddSubscriptionList(ctx context.Context, userID string, userIDList []string) error
- func (u *UserMongoDriver) GetAllSubscribeList(ctx context.Context, userID string) (userIDList []string, err error)
- func (u *UserMongoDriver) GetSubscribedList(ctx context.Context, userID string) (userIDList []string, err error)
- func (u *UserMongoDriver) RemoveSubscribedListFromUser(ctx context.Context, userID string, userIDList []string) error
- func (u *UserMongoDriver) UnsubscriptionList(ctx context.Context, userID string, userIDList []string) error
Constants ¶
View Source
const ( SubscriptionPrefix = "subscription_prefix" SubscribedPrefix = "subscribed_prefix" )
prefixes and suffixes.
View Source
const (
MaximumSubscription = 3000
)
MaximumSubscription Maximum number of subscriptions.
Variables ¶
View Source
var ErrMsgListNotExist = errors.New("user not have msg in mongoDB")
Functions ¶
func NewMsgMongoDriver ¶
func NewMsgMongoDriver(database *mongo.Database) table.MsgDocModelInterface
func NewSuperGroupMongoDriver ¶
func NewSuperGroupMongoDriver(database *mongo.Database) unrelation.SuperGroupModelInterface
func NewUserMongoDriver ¶
func NewUserMongoDriver(database *mongo.Database) unrelation.UserModelInterface
Types ¶
type Mongo ¶
type Mongo struct {
// contains filtered or unexported fields
}
func (*Mongo) CreateMsgIndex ¶
func (*Mongo) CreateSuperGroupIndex ¶
func (*Mongo) GetDatabase ¶
type MsgMongoDriver ¶
type MsgMongoDriver struct { MsgCollection *mongo.Collection // contains filtered or unexported fields }
func (*MsgMongoDriver) ConvertMsgsDocLen ¶
func (m *MsgMongoDriver) ConvertMsgsDocLen(ctx context.Context, conversationIDs []string)
func (*MsgMongoDriver) Create ¶
func (m *MsgMongoDriver) Create(ctx context.Context, model *table.MsgDocModel) error
func (*MsgMongoDriver) DeleteDocs ¶
func (m *MsgMongoDriver) DeleteDocs(ctx context.Context, docIDs []string) error
func (*MsgMongoDriver) DeleteMsgsInOneDocByIndex ¶
func (*MsgMongoDriver) FindOneByDocID ¶
func (m *MsgMongoDriver) FindOneByDocID(ctx context.Context, docID string) (*table.MsgDocModel, error)
func (*MsgMongoDriver) GetMsgBySeqIndexIn1Doc ¶
func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc( ctx context.Context, userID string, docID string, seqs []int64, ) (msgs []*table.MsgInfoModel, err error)
func (*MsgMongoDriver) GetMsgDocModelByIndex ¶
func (m *MsgMongoDriver) GetMsgDocModelByIndex( ctx context.Context, conversationID string, index, sort int64, ) (*table.MsgDocModel, error)
func (*MsgMongoDriver) GetNewestMsg ¶
func (m *MsgMongoDriver) GetNewestMsg(ctx context.Context, conversationID string) (*table.MsgInfoModel, error)
func (*MsgMongoDriver) GetOldestMsg ¶
func (m *MsgMongoDriver) GetOldestMsg(ctx context.Context, conversationID string) (*table.MsgInfoModel, error)
func (*MsgMongoDriver) IsExistDocID ¶
func (*MsgMongoDriver) MarkSingleChatMsgsAsRead ¶
func (*MsgMongoDriver) PushMsgsToDoc ¶
func (m *MsgMongoDriver) PushMsgsToDoc(ctx context.Context, docID string, msgsToMongo []table.MsgInfoModel) error
func (*MsgMongoDriver) PushUnique ¶
func (m *MsgMongoDriver) PushUnique( ctx context.Context, docID string, index int64, key string, value any, ) (*mongo.UpdateResult, error)
PushUnique value must slice.
func (*MsgMongoDriver) RangeGroupSendCount ¶
func (*MsgMongoDriver) RangeUserSendCount ¶
func (m *MsgMongoDriver) RangeUserSendCount( ctx context.Context, start time.Time, end time.Time, group bool, ase bool, pageNumber int32, showNumber int32, ) (msgCount int64, userCount int64, users []*table.UserCount, dateCount map[string]int64, err error)
RangeUserSendCount db.msg.aggregate([
{ $match: { "msgs.msg.send_time": { "$gte": 0, "$lt": 1788122092317 } } }, { "$addFields": { "msgs": { "$filter": { "input": "$msgs", "as": "item", "cond": { "$and": [ { $gte: ["$$item.msg.send_time", 0] }, { $lt: ["$$item.msg.send_time", 1788122092317] } ] } } } } }, { "$project": { "_id": 0, }, }, { "$project": { "result": { "$map": { "input": "$msgs", "as": "item", "in": { user_id: "$$item.msg.send_id", send_date: { $dateToString: { format: "%Y-%m-%d", date: { $toDate: "$$item.msg.send_time" } } } } } } }, }, { "$unwind": "$result" }, { "$group": { _id: "$result.send_date", count: { $sum: 1 }, original: { $push: "$$ROOT" } } }, { "$addFields": { "dates": "$$ROOT" } }, { "$project": { "_id": 0, "count": 0, "dates.original": 0, }, }, { "$group": { _id: null, count: { $sum: 1 }, dates: { $push: "$dates" }, original: { $push: "$original" }, } }, { "$unwind": "$original" }, { "$unwind": "$original" }, { "$group": { _id: "$original.result.user_id", count: { $sum: 1 }, original: { $push: "$dates" }, } }, { "$addFields": { "dates": { $arrayElemAt: ["$original", 0] } } }, { "$project": { original: 0 } }, { $sort: { count: - 1 } }, { "$group": { _id: null, user_count: { $sum: 1 }, users: { $push: "$$ROOT" }, } }, { "$addFields": { "dates": { $arrayElemAt: ["$users", 0] } } }, { "$addFields": { "dates": "$dates.dates" } }, { "$project": { _id: 0, "users.dates": 0, } }, { "$addFields": { "msg_count": { $sum: "$users.count" } } }, { "$addFields": { users: { $slice: ["$users", 0, 10] } } }
]).
func (*MsgMongoDriver) SearchMessage ¶
func (m *MsgMongoDriver) SearchMessage(ctx context.Context, req *msg.SearchMessageReq) (int32, []*table.MsgInfoModel, error)
func (*MsgMongoDriver) UpdateMsg ¶
func (m *MsgMongoDriver) UpdateMsg( ctx context.Context, docID string, index int64, key string, value any, ) (*mongo.UpdateResult, error)
func (*MsgMongoDriver) UpdateMsgContent ¶
type SuperGroupMongoDriver ¶
type SuperGroupMongoDriver struct {
// contains filtered or unexported fields
}
func (*SuperGroupMongoDriver) AddUserToSuperGroup ¶
func (*SuperGroupMongoDriver) CreateSuperGroup ¶
func (*SuperGroupMongoDriver) DeleteSuperGroup ¶
func (s *SuperGroupMongoDriver) DeleteSuperGroup(ctx context.Context, groupID string) error
func (*SuperGroupMongoDriver) FindSuperGroup ¶
func (s *SuperGroupMongoDriver) FindSuperGroup( ctx context.Context, groupIDs []string, ) (groups []*unrelation.SuperGroupModel, err error)
func (*SuperGroupMongoDriver) GetSuperGroupByUserID ¶
func (s *SuperGroupMongoDriver) GetSuperGroupByUserID( ctx context.Context, userID string, ) (*unrelation.UserToSuperGroupModel, error)
func (*SuperGroupMongoDriver) RemoveGroupFromUser ¶
func (*SuperGroupMongoDriver) RemoverUserFromSuperGroup ¶
func (*SuperGroupMongoDriver) TakeSuperGroup ¶
func (s *SuperGroupMongoDriver) TakeSuperGroup( ctx context.Context, groupID string, ) (group *unrelation.SuperGroupModel, err error)
type UserMongoDriver ¶
type UserMongoDriver struct {
// contains filtered or unexported fields
}
func (*UserMongoDriver) AddSubscriptionList ¶
func (u *UserMongoDriver) AddSubscriptionList(ctx context.Context, userID string, userIDList []string) error
AddSubscriptionList Subscriber's handling of thresholds.
func (*UserMongoDriver) GetAllSubscribeList ¶
func (u *UserMongoDriver) GetAllSubscribeList(ctx context.Context, userID string) (userIDList []string, err error)
GetAllSubscribeList Get all users subscribed by this user.
func (*UserMongoDriver) GetSubscribedList ¶
func (u *UserMongoDriver) GetSubscribedList(ctx context.Context, userID string) (userIDList []string, err error)
GetSubscribedList Get the user subscribed by those users.
func (*UserMongoDriver) RemoveSubscribedListFromUser ¶
func (u *UserMongoDriver) RemoveSubscribedListFromUser(ctx context.Context, userID string, userIDList []string) error
RemoveSubscribedListFromUser Among the unsubscribed users, delete the user from the subscribed list.
func (*UserMongoDriver) UnsubscriptionList ¶
func (u *UserMongoDriver) UnsubscriptionList(ctx context.Context, userID string, userIDList []string) error
UnsubscriptionList Handling of unsubscribe.
Click to show internal directories.
Click to hide internal directories.