當前位置: 首頁>>代碼示例>>Golang>>正文


Golang common.MongoCollection函數代碼示例

本文整理匯總了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
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:7,代碼來源:user.go

示例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)
	}
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:7,代碼來源:user.go

示例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)
	}
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:7,代碼來源:user.go

示例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
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:7,代碼來源:user.go

示例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
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:8,代碼來源:member.go

示例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
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:8,代碼來源:qiniu.go

示例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
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:8,代碼來源:user.go

示例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)
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:8,代碼來源:team.go

示例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
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:9,代碼來源:team.go

示例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))
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:9,代碼來源:user.go

示例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
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:9,代碼來源:member.go

示例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
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:9,代碼來源:friend.go

示例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
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:9,代碼來源:user.go

示例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)
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:10,代碼來源:qiniu.go

示例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))
}
開發者ID:sunyuantao,項目名稱:windows,代碼行數:11,代碼來源:friend.go


注:本文中的project/common.MongoCollection函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。