// GetFortunes selects all fortunes from table
GetFortunes selects all fortunes from table
// GetFortunes selects all fortunes from table
func (m Mongo) GetFortunes() (templates.Fortunes, error) {
	fortunes := templates.AcquireFortunes()
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()
	cur, err := m.fortunes.Find(ctx, bson.M{})
	if err != nil {
		return fortunes, err
	}
	defer cur.Close(ctx)
	fortune := templates.AcquireFortune()
	for cur.Next(context.Background()) {
		err = cur.Decode(fortune)
		if err != nil {
			return fortunes, err
		}
		fortunes = append(fortunes, *fortune)
	}
	templates.ReleaseFortune(fortune)
	if err := cur.Err(); err != nil {
		return fortunes, err
	}
	return fortunes, nil
}
func ( m Mongo ) GetFortunes ( ) ( templates . Fortunes , error ) { fortunes := templates . AcquireFortunes ( ) ctx , cancel := context . WithTimeout ( context . Background ( ) , 10 * time . Second ) defer cancel ( ) cur , err := m . fortunes . Find ( ctx , bson . M { } ) if err != nil { return fortunes , err } defer cur . Close ( ctx ) fortune := templates . AcquireFortune ( ) for cur . Next ( context . Background ( ) ) { err = cur . Decode ( fortune ) if err != nil { return fortunes , err } fortunes = append ( fortunes , * fortune ) } templates . ReleaseFortune ( fortune ) if err := cur . Err ( ) ; err != nil { return fortunes , err } return fortunes , nil }
GetFortunes selects all fortunes from table
GetFortunes selects all fortunes from table