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


Golang mongo.GetSession函數代碼示例

本文整理匯總了Golang中github.com/xing4git/chirp/mongo.GetSession函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetSession函數的具體用法?Golang GetSession怎麽用?Golang GetSession使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetSession函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: RemoveFollow

func RemoveFollow(uid string, beuid string) (err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_FOLLOW)

	return c.Remove(bson.M{"uid": uid, "beuid": beuid})
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:7,代碼來源:followDao.go

示例2: InsertFeedLoc

func InsertFeedLoc(loc model.FeedLoc) (ret model.FeedLoc, err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_FEED_LOC)

	return loc, c.Insert(loc)
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:7,代碼來源:feedLocDao.go

示例3: UserLogin

func UserLogin(uid string) (err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_USER_EXPAND)
	err = c.Update(bson.M{"uid": uid}, bson.M{"$set": bson.M{"lltime": util.UnixMillSeconds()}, "$inc": bson.M{"logincnt": 1}})
	return
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:7,代碼來源:userExpandDao.go

示例4: RemoveFeed

func RemoveFeed(id bson.ObjectId) (err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_FEED)

	return c.RemoveId(id)
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:7,代碼來源:feedDao.go

示例5: RemoveFeedLoc

func RemoveFeedLoc(id string) (err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_FEED_LOC)

	return c.Remove(bson.M{"fid": id})
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:7,代碼來源:feedLocDao.go

示例6: InsertFollow

func InsertFollow(follow model.Follow) (ret model.Follow, err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_FOLLOW)

	follow.Ctime = util.UnixMillSeconds()
	return follow, c.Insert(follow)
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:8,代碼來源:followDao.go

示例7: UpdateUserExpand

func UpdateUserExpand(ue model.UserExpand) (ret model.UserExpand, err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_USER_EXPAND)

	cmd := bson.D{{"findAndModify", util.MONGO_COLLECTION_USER_EXPAND}, {"new", true}, {"query", bson.M{"uid": ue.Uid}}, {"update", bson.M{"$set": ue.UserExpandToBson()}}}
	err = c.Database.Run(cmd, &ret)
	return
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:9,代碼來源:userExpandDao.go

示例8: InsertComment

func InsertComment(comment model.Comment) (ret model.Comment, err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_COMMENT)

	comment.Cid = bson.NewObjectId()
	comment.Ctime = util.UnixMillSeconds()

	return comment, c.Insert(comment)
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:10,代碼來源:commentDao.go

示例9: InsertUser

func InsertUser(user model.User) (ret model.User, err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_USER)

	user.Uid = bson.NewObjectId()
	user.Ctime = util.UnixMillSeconds()

	return user, c.Insert(user)
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:10,代碼來源:userDao.go

示例10: InsertFeed

func InsertFeed(feed model.Feed) (ret model.Feed, err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_FEED)

	feed.Fid = bson.NewObjectId()
	feed.Ctime = util.UnixMillSeconds()

	return feed, c.Insert(feed)
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:10,代碼來源:feedDao.go

示例11: QueryFollow

func QueryFollow(uid string, beuid string) (ret model.Follow, err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_FOLLOW)

	q := c.Find(bson.M{"uid": uid, "beuid": beuid})
	if q.Iter().Next(&ret) {
		return ret, nil
	}
	return ret, mgo.ErrNotFound
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:11,代碼來源:followDao.go

示例12: QueryFeedLoc

func QueryFeedLoc(id string) (ret model.FeedLoc, err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_FEED_LOC)

	q := c.Find(bson.M{"fid": id})
	if q.Iter().Next(&ret) {
		return ret, nil
	}
	return ret, mgo.ErrNotFound
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:11,代碼來源:feedLocDao.go

示例13: QueryUserExpand

func QueryUserExpand(id string) (ret model.UserExpand, err error) {
	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_USER_EXPAND)

	q := c.Find(bson.M{"uid": id})
	if q.Iter().Next(&ret) {
		return ret, nil
	}
	return ret, mgo.ErrNotFound
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:11,代碼來源:userExpandDao.go

示例14: InsertCommentsDel

func InsertCommentsDel(comments []model.Comment) (err error) {
	ins := make([]interface{}, len(comments), len(comments))
	for pos, v := range comments {
		ins[pos] = v
	}

	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_COMMENT_DEL)
	return c.Insert(ins...)
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:11,代碼來源:commentDao.go

示例15: InsertUserLocsDel

func InsertUserLocsDel(locs []model.UserLoc) (err error) {
	ins := make([]interface{}, len(locs), len(locs))
	for pos, v := range locs {
		ins[pos] = v
	}

	s := mongo.GetSession()
	defer s.Close()
	c := collection(s, util.MONGO_COLLECTION_USER_LOC_DEL)
	return c.Insert(ins...)
}
開發者ID:xing4git,項目名稱:chirp,代碼行數:11,代碼來源:userLocDao.go


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