Documentation ¶
Index ¶
- Variables
- func GetJoinUserId(userId1, userId2 int64) string
- func UpdateDelayMessage(userId int64, message []byte) error
- func UpdateGroupChatHistoryById(groupId int64, message []byte) error
- func UpdateGroupChatUserToAddOne(groupChatId, managerId, userId int64) error
- func UpdateGroupChatUsersToDelOne(groupChatId, userId int64) error
- func UpdateMakeUserFollowSubscription(userId, subsId int64) error
- func UpdateMakeUserUnFollowSubscription(userId, subsId int64) error
- func UpdateMoveFriendIntoBlacklistPlus(userId, friendId int64) error
- func UpdateMoveFriendOutFromBlacklistPlus(userId, friendId int64) error
- func UpdateMoveUserIntoGroupChat(userId, groupChatId int64) error
- func UpdateMoveUserOutFromGroupChat(userId, groupChatId int64) error
- func UpdateSubscriptionHistoryById(subsId int64, message []byte) error
- func UpdateSubscriptionUsersToAddOne(subsId, managerId, userId int64) error
- func UpdateSubscriptionUsersToDelOne(subsId, userId int64) error
- func UpdateUserBlacklistToAddUser(userId, anotherId int64) error
- func UpdateUserBlacklistToDelUser(userId, anotherId int64) error
- func UpdateUserChatHistoryByJoinId(joinUserId string, message []byte) error
- func UpdateUserFriendsToAddFriend(userId, friendId int64) error
- func UpdateUserFriendsToDelFriend(userId, friendId int64) error
- func UpdateUserGroupChatsToAddOne(userId, groupChatId int64) error
- func UpdateUserGroupChatsToDelOne(userId, groupChatId int64) error
- func UpdateUserSubscriptionsToAddOne(userId, subsId int64) error
- func UpdateUserSubscriptionsToDelOne(userId, subsId int64) error
- type DocDelayMessage
- type DocGroupChatHistory
- type DocGroupChatUsers
- type DocSubscriptionHistory
- type DocSubscriptionUsers
- type DocUserChatHistory
- func FindUserAllChatHistoryByJoinId(joinUserId string) (*DocUserChatHistory, error)
- func FindUserChatHistoryByJoinIdAndDate(joinUserId string, date int32) (*DocUserChatHistory, error)
- func FindUserChatHistoryByJoinIdAndDateRange(joinUserId string, startDate, endDate int32) (*DocUserChatHistory, error)
- type DocUserFriends
- type DocUserGroupChats
- type DocUserSubscriptions
Constants ¶
This section is empty.
Variables ¶
var ( CollDelayMessage *mongo.Collection // the message for the user when him was offline. CollUserChatHistory *mongo.Collection // the history of the message which between two user. CollGroupChatHistory *mongo.Collection // the history of the message which belong the group chat. CollSubscriptionMsgHistory *mongo.Collection // the history of the message which belong the subscription. CollUserFriends *mongo.Collection // the id of user's friends, include the blacklist. CollUserGroupChats *mongo.Collection // the id of the group chat which the user was joined. CollUserSubscriptions *mongo.Collection // the id of the subscription which the user was followed CollGroupChatUsers *mongo.Collection // the id of users whom are belong to the group chat. CollSubscriptionUsers *mongo.Collection // the id of users whom are followed the subscription. )
var ( ErrFoundCount = errors.New("the found count should be 0 or 1") ErrMessageHistoryNotFound = errors.New("the message history not found") )
Custom errors:
Functions ¶
func GetJoinUserId ¶
Return a string joined by two user's id
func UpdateDelayMessage ¶
Update the delay message of the user. If the document not existed, will insert new one with the data.
func UpdateGroupChatHistoryById ¶
Update the message history record for the group chat.
func UpdateGroupChatUserToAddOne ¶
Update the 'users' array to add one user id.
func UpdateGroupChatUsersToDelOne ¶
Update the 'users' array to delete one user id.
func UpdateMakeUserFollowSubscription ¶
Update the 'subscription' array in document which in 'user_subscriptions' collection, and the 'users' array in document which in 'subscription_users' collection at the same time.
func UpdateMoveFriendIntoBlacklistPlus ¶
Update the 'friends' and 'blacklist' array to move a friend id into 'blacklist' from 'friends' .
func UpdateMoveFriendOutFromBlacklistPlus ¶
Update the 'friends' and 'blacklist' array to move a friend id into 'friends' from 'blacklist'
func UpdateMoveUserIntoGroupChat ¶
Update the 'groups' array in document which in 'user_group_chats' collection, and the 'users' array in document which in 'group_chat_users' collection at the same time.
func UpdateSubscriptionHistoryById ¶
Update the message history record for the subscription
func UpdateSubscriptionUsersToAddOne ¶
Update the 'users' array to add one user id.
func UpdateSubscriptionUsersToDelOne ¶
Update the 'users' array to delete one user id.
func UpdateUserBlacklistToAddUser ¶
Update the 'blacklist' array to add one user id.
func UpdateUserBlacklistToDelUser ¶
Update the 'blacklist' array to delete one user id.
func UpdateUserChatHistoryByJoinId ¶
Update the chat history between two users.
func UpdateUserFriendsToAddFriend ¶
Update the 'friends' array to add one new friend's id.
func UpdateUserFriendsToDelFriend ¶
Update the 'friends' array to delete one friend's id.
func UpdateUserGroupChatsToAddOne ¶
Update the 'groups' array to add one group chat id.
func UpdateUserGroupChatsToDelOne ¶
Update the 'groups' array to delete one group chat id.
func UpdateUserSubscriptionsToAddOne ¶
Update the 'subscription' array to add one subscription id.
func UpdateUserSubscriptionsToDelOne ¶
Update the 'subscription' array to delete one subscription id.
Types ¶
type DocDelayMessage ¶
delay_message document eg.:
{ "_id": <user_id>, "messages": [ <the message bytes data: eg. []byte("test message string")>, ... ] }
information for delay message
func FindAndDeleteDelayMessage ¶
func FindAndDeleteDelayMessage(userId int64) (*DocDelayMessage, error)
Find and delete the delay message of the user from collection.
type DocGroupChatHistory ¶
type DocGroupChatHistory struct { GroupId int64 `bson:"_id"` History []historyMessage `bson:"history"` }
group_chat_history document eg.:
{ "_id": <the group chat id>, "history": [ { "date": <date number: eg. 20190303>, "messages": [ <the message bytes data eg.: []byte("test message string")>, .... ] }, ... ] }
information for group chat history.
func FindAllGroupChatHistoryById ¶
func FindAllGroupChatHistoryById(groupId int64) (*DocGroupChatHistory, error)
Find the all chat history of the group chat by group id.
func FindGroupChatHistoryByIdAndDate ¶
func FindGroupChatHistoryByIdAndDate(groupId int64, date int32) (*DocGroupChatHistory, error)
Find many group chat history of the group chat by group id and a special date.
func FindGroupChatHistoryByIdAndDateRange ¶
func FindGroupChatHistoryByIdAndDateRange(groupId int64, startDate, endDate int32) (*DocGroupChatHistory, error)
Find many group chat history of the group chat by group id and date range.
type DocGroupChatUsers ¶
type DocGroupChatUsers struct { GroupId int64 `bson:"_id"` ManagerId int64 `bson:"manager"` Users []int64 `bson:"users"` }
group_chat_users document eg.:
{ "_id": <the group chat id>, "manager": <the user id>, "users" : [ <the user id>, <the user id>, ... ] }
information for the users which belong to the group chat
func FindGroupChatUsersById ¶
func FindGroupChatUsersById(groupChatId int64) (*DocGroupChatUsers, error)
type DocSubscriptionHistory ¶
type DocSubscriptionHistory struct { SubsId int64 `bson:"_id"` History []historyMessage `bson:"history"` }
subscription_msg_history document eg.:
{ "_id": <the subscription id>, "history": [ { "date": <date number: eg. 20190303>, "messages": [ <the message bytes data eg.: []byte("test message string")>, .... ] }, ... ] }
information for subscription message history.
func FindAllSubscriptionHistoryById ¶
func FindAllSubscriptionHistoryById(subsId int64) (*DocSubscriptionHistory, error)
Find the all subscription message history of the subscription by the id.
func FindSubscriptionHistoryByIdAndDate ¶
func FindSubscriptionHistoryByIdAndDate(subsId int64, date int32) (*DocSubscriptionHistory, error)
Find many subscription history of the subscription by id and a special date.
func FindSubscriptionHistoryByIdAndDateRange ¶
func FindSubscriptionHistoryByIdAndDateRange(subsId int64, startDate, endDate int32) (*DocSubscriptionHistory, error)
Find many subscription history of the subscription by id and date range.
type DocSubscriptionUsers ¶
type DocSubscriptionUsers struct { SubsId int64 `bson:"_id"` ManagerId int64 `bson:"manager"` Users []int64 `bson:"users"` }
subscription_users document eg.:
{ "_id": <the subscription id>, "manager": <the user id>, "users" : [ <the user id>, <the user id>, ... ] }
information for the users which followed the subscription.
func FindSubscriptionUsersById ¶
func FindSubscriptionUsersById(subsId int64) (*DocSubscriptionUsers, error)
type DocUserChatHistory ¶
type DocUserChatHistory struct { Id string `bson:"_id"` History []historyMessage `bson:"history"` }
user_chat_history document eg.:
{ "_id" : <join_user_id eg.: 1_2>, "history": [ { "date": <date number: eg. 20190303>, "messages": [ <the message bytes data eg.: []byte("test message string")>, .... ] }, ... ] }
information for user chat history
func FindUserAllChatHistoryByJoinId ¶
func FindUserAllChatHistoryByJoinId(joinUserId string) (*DocUserChatHistory, error)
Find all chat history between two users by their id.
func FindUserChatHistoryByJoinIdAndDate ¶
func FindUserChatHistoryByJoinIdAndDate(joinUserId string, date int32) (*DocUserChatHistory, error)
Find one chat history between two users by their id and a special date
func FindUserChatHistoryByJoinIdAndDateRange ¶
func FindUserChatHistoryByJoinIdAndDateRange(joinUserId string, startDate, endDate int32) (*DocUserChatHistory, error)
Find many chat history between two users by their id and the date range
type DocUserFriends ¶
type DocUserFriends struct { UserId int64 `bson:"_id"` Friends []int64 `bson:"friends"` Blacklist []int64 `bson:"blacklist"` }
user_friends document eg.:
{ "_id": <the user id>, "friends": [ <another user id>, <another user id>, ... ], "blacklist": [ <another user id>, <another user id>, ... ] }
information for user's friends.
func FindUserFriendsAndBlacklistById ¶
func FindUserFriendsAndBlacklistById(userId int64) (*DocUserFriends, error)
type DocUserGroupChats ¶
user_group_chats document eg.:
{ "_id": <the user id>, "groups": [ <the group chat id>, <the group chat id>, ... ] }
information for the group chat which the user had joined.
func FindUserGroupChatsById ¶
func FindUserGroupChatsById(userId int64) (*DocUserGroupChats, error)
type DocUserSubscriptions ¶
type DocUserSubscriptions struct { UserId int64 `bson:"_id"` Subscriptions []int64 `bson:"subscriptions"` }
user_subscriptions document eg.:
{ "_id": <the user id>, "subscriptions": [ <the subscription id>, <the subscription id>, ... ] }
information for the subscription which the user had followed.
func FindUserSubscriptionsById ¶
func FindUserSubscriptionsById(userId int64) (*DocUserSubscriptions, error)