本文整理汇总了Golang中project/common.MongoCollection函数的典型用法代码示例。如果您正苦于以下问题:Golang MongoCollection函数的具体用法?Golang MongoCollection怎么用?Golang MongoCollection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MongoCollection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DeleteUserInfoByUid
func DeleteUserInfoByUid(uid uint64) error {
c := common.MongoCollection(USER_DB, USER_INFO_TABLE)
if err := c.Remove(bson.M{"uid": uid}); err != nil {
return errors.As(err, uid)
}
return nil
}
示例2: SafeMapTimeoutCall
func (msg *UserMsgItem) SafeMapTimeoutCall(key interface{}) {
// 超时未删除则保存到db
c := common.MongoCollection(MSG_DB, MSG_USER_MSG_TABLE)
if err := c.Insert(msg); err != nil {
syslog.Info(err, *msg)
}
}
示例3: SaveUserMsgToDB
func SaveUserMsgToDB(userMsg *UserMsgItem) {
// 超时未删除则保存到db
c := common.MongoCollection(MSG_DB, MSG_USER_MSG_TABLE)
if err := c.Insert(userMsg); err != nil {
syslog.Info(err, *userMsg)
}
}
示例4: SetUserInfo
func SetUserInfo(sel, set map[string]interface{}) error {
c := common.MongoCollection(USER_DB, USER_INFO_TABLE)
if err := c.Update(bson.M(sel), bson.M{"$set": bson.M(set)}); err != nil {
return errors.As(err, sel, set)
}
return nil
}
示例5: SetTeamMember
func SetTeamMember(sel, set map[string]interface{}) error {
c := common.MongoCollection(TEAM_DB, TEAM_MEMBER_TABLE)
if err := c.Update(bson.M(sel), bson.M{"$set": bson.M(set)}); err != nil {
return errors.As(err, sel, set)
}
return nil
}
示例6: deleteFile
func deleteFile(filelist []string) error {
c := common.MongoCollection(FILE_DB, FILE_QINIU_FILE_TABLE)
_, err := c.RemoveAll(bson.M{"filename": bson.M{"$in": filelist}})
if err != nil && err != mgo.ErrNotFound {
return errors.As(err, filelist)
}
return nil
}
示例7: GetUserCount
func GetUserCount() (uint64, error) {
c := common.MongoCollection(USER_DB, USER_INFO_TABLE)
count, err := c.Find(nil).Count()
if err != nil {
return 0, errors.As(err)
}
return uint64(count), nil
}
示例8: GetTeamList
func GetTeamList(sel map[string]interface{}, start, count int) ([]TeamInfo, error) {
c := common.MongoCollection(TEAM_DB, TEAM_INFO_TABLE)
team_list := []TeamInfo{}
err := c.Find(bson.M(sel)).Skip(start).Limit(count).All(&team_list)
return team_list, errors.As(err, sel)
}
示例9: DeleteTeam
func DeleteTeam(teamid uint64) error {
c := common.MongoCollection(TEAM_DB, TEAM_INFO_TABLE)
err := c.Remove(bson.M{"teamid": teamid})
if err != mgo.ErrNotFound {
return errors.As(err, teamid)
}
return nil
}
示例10: UserMsgInit
func UserMsgInit() error {
c := common.MongoCollection(MSG_DB, MSG_USER_MSG_TABLE)
index := mgo.Index{
Key: []string{"touid", "msgid"},
}
return errors.As(c.EnsureIndex(index))
}
示例11: DeleteTeamMember
func DeleteTeamMember(teamid, uid uint64) error {
c := common.MongoCollection(TEAM_DB, TEAM_MEMBER_TABLE)
err := c.Remove(bson.M{"teamid": teamid, "uid": uid})
if err != mgo.ErrNotFound {
return errors.As(err, uid, teamid)
}
return nil
}
示例12: DeleteFriend
func DeleteFriend(uid, fid uint64) error {
c := common.MongoCollection(USER_DB, USER_FRIEND_TABLE)
err := c.Remove(bson.M{"fuid": fid, "uid": uid})
if err != mgo.ErrNotFound {
return errors.As(err, fid)
}
return nil
}
示例13: GetUserInfo
func GetUserInfo(sel map[string]interface{}) (*UserInfo, error) {
c := common.MongoCollection(USER_DB, USER_INFO_TABLE)
user := &UserInfo{}
if err := c.Find(bson.M(sel)).One(user); err != nil {
return nil, errors.As(err, sel)
}
return user, nil
}
示例14: addFile
func addFile(file *File) error {
c := common.MongoCollection(FILE_DB, FILE_QINIU_FILE_TABLE)
sel := bson.M{"filename": file.Filename}
set := bson.M{
"$set": bson.M{"expiredtime": file.ExpiredTime},
"$setOnInsert": bson.M{"createtime": file.CreateTime},
}
_, err := c.Upsert(sel, set)
return errors.As(err, *file)
}
示例15: FriendInit
func FriendInit() error {
c := common.MongoCollection(USER_DB, USER_FRIEND_TABLE)
index := mgo.Index{
Key: []string{"uid", "fuid"},
Unique: true,
DropDups: true,
}
return errors.As(c.EnsureIndex(index))
}