示例#1
0
func (u *User) Get(w *wrapper.Wrapper) error {
	c := w.DbSession.DB("").C("users")
	var id bson.M
	w.GetSessionValue("user_id", &id)
	if id == nil {
		err := errors.New("User not found")
		return err
	}
	if user_id, ok := id["user_id"]; ok {
		err := c.Find(bson.M{"_id": user_id}).One(u)
		return err
	} else {
		err := errors.New("User not found")
		return err
	}
}