本文整理汇总了Golang中github.com/xing4git/chirp/mongo.GetSession函数的典型用法代码示例。如果您正苦于以下问题:Golang GetSession函数的具体用法?Golang GetSession怎么用?Golang GetSession使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetSession函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: InsertUserExpandsDel
func InsertUserExpandsDel(ues []model.UserExpand) (err error) {
ins := make([]interface{}, len(ues), len(ues))
for pos, v := range ues {
ins[pos] = v
}
s := mongo.GetSession()
defer s.Close()
c := collection(s, util.MONGO_COLLECTION_USER_EXPAND_DEL)
return c.Insert(ins...)
}
开发者ID:xing4git,项目名称:chirp,代码行数:11,代码来源:userExpandDao.go
示例17: QueryFeed
func QueryFeed(id bson.ObjectId) (ret model.Feed, err error) {
s := mongo.GetSession()
defer s.Close()
c := collection(s, util.MONGO_COLLECTION_FEED)
q := c.FindId(id)
if q.Iter().Next(&ret) {
return ret, nil
}
return ret, mgo.ErrNotFound
}
开发者ID:xing4git,项目名称:chirp,代码行数:11,代码来源:feedDao.go
示例18: InsertFeedsDel
func InsertFeedsDel(feeds []model.Feed) (err error) {
ins := make([]interface{}, len(feeds), len(feeds))
for pos, v := range feeds {
ins[pos] = v
}
s := mongo.GetSession()
defer s.Close()
c := collection(s, util.MONGO_COLLECTION_FEED_DEL)
return c.Insert(ins...)
}
开发者ID:xing4git,项目名称:chirp,代码行数:11,代码来源:feedDao.go
示例19: QueryBatchUserExpand
func QueryBatchUserExpand(ids []string) (rets []model.UserExpand, err error) {
s := mongo.GetSession()
defer s.Close()
c := collection(s, util.MONGO_COLLECTION_USER_EXPAND)
iter := c.Find(bson.M{"uid": bson.M{"$in": ids}}).Iter()
rets = make([]model.UserExpand, 0, len(ids))
item := model.UserExpand{}
for iter.Next(&item) {
rets = append(rets, item)
}
return rets, nil
}
开发者ID:xing4git,项目名称:chirp,代码行数:13,代码来源:userExpandDao.go
示例20: queryComments
func queryComments(idName string, id string) (rets []model.Comment) {
rets = make([]model.Comment, 0, 20)
s := mongo.GetSession()
defer s.Close()
c := collection(s, util.MONGO_COLLECTION_COMMENT)
iter := c.Find(bson.M{idName: id}).Iter()
item := model.Comment{}
for iter.Next(&item) {
rets = append(rets, item)
}
return
}
开发者ID:xing4git,项目名称:chirp,代码行数:13,代码来源:commentDao.go
注:本文中的github.com/xing4git/chirp/mongo.GetSession函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论