func (s *Service) GetSessionInfo(sessionId string) (si SessionInformation, err error) { SessionQuery := bson.M{"sessionid": sessionId} db := s.DB.Copy() defer db.Close() err = db.FindOne("sessions", SessionQuery, &si) return si, err }
func (s *Service) RemoveAllSession() int { db := s.DB.Copy() defer db.Close() removed, err := s.DB.RemoveCollection("sessions", bson.M{"lastupdatedtime": bson.M{"$lt": time.Now()}}) if err != nil { log.Fatal(err) } return removed }
func (s *Service) UpsertSession(sessionId string) { si := SessionInformation{} si.LastUpdatedTime = time.Now() si.SessionId = sessionId db := s.DB.Copy() defer db.Close() err := db.UpsertSession("sessions", bson.M{"sessionid": sessionId}, si) if err != nil { log.Fatal(err) } }
func userExist(f *fishhub.Service, email string) bool { db := f.DB.Copy() defer db.Close() ui := UserProfile{} query := bson.M{"email": email} err := db.FindOne("users", query, &ui) if err == mgo.ErrNotFound { return false } else { return true } return false }