func (u *User) Save() error { session := env.NewMongoSession() defer session.Close() c := session.DB(env.Config.Mongo.Db).C(collection) return c.Insert(&u) }
func getSessionById(sid string) *JustilySession { s := env.NewMongoSession() defer s.Close() id := bson.ObjectIdHex(sid) coll := getCollection(s) js := &JustilySession{} coll.Find(bson.M{"_id": id}).One(js) return js }
func ById(id string) (*User, error) { session := env.NewMongoSession() defer session.Close() u := &User{} c := session.DB(env.Config.Mongo.Db).C(collection) err := c.Find(bson.M{"_id": id}).One(u) return u, err }
func NewSession() *JustilySession { s := env.NewMongoSession() defer s.Close() id := bson.NewObjectId() js := &JustilySession{Id: id, LastAccessedTime: time.Now(), Business: "0"} coll := getCollection(s) coll.Insert(js) return js }