Esempio n. 1
0
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)
}
Esempio n. 2
0
func redisUsers(key string, from int64, to int64) (rets []model.User, err error) {
	var strs []string
	strs, err = redisStrs(key, from, to)
	if err != nil {
		return nil, err
	}

	rets = make([]model.User, len(strs))
	for pos, str := range strs {
		user := model.User{}
		user.Uid = bson.ObjectIdHex(str)
		rets[pos] = user
	}
	return
}