本文整理汇总了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})
}
示例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)
}
示例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
}
示例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)
}
示例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})
}
示例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)
}
示例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
}
示例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)
}
示例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)
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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...)
}
示例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...)
}