当前位置: 首页>>代码示例>>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;未经允许,请勿转载。