func (service *Service) GetAllEvents(ctx context.Context) ([]*mms.ProductEvent, error) {
	rows, err := service.eventsDB.QueryContext(ctx, "SELECT * FROM events")
	if err != nil {
		return nil, fmt.Errorf("could not access db to get events: %s", err)
	}
	defer rows.Close()

	var events []*mms.ProductEvent
	for rows.Next() {
		var id int
		var createdAt string
		var payload []byte
		rows.Scan(&id, &createdAt, &payload)

		var event mms.ProductEvent
		if err := json.Unmarshal(payload, &event); err != nil {
			log.Printf("failed to unmarshal an event from db: %s", err)
		} else {
			events = append(events, &event)
		}
	}
	return events, nil
}
// GetAllEvents returns all product events in the events database.
GetAllEvents returns all product events in the events database.
// GetAllEvents returns all product events in the events database .
func (service *Service) GetAllEvents(ctx context.Context) ([]*mms.ProductEvent, error) {
	rows, err := service.eventsDB.QueryContext(ctx, "SELECT * FROM events")
	if err != nil {
		return nil, fmt.Errorf("could not access db to get events: %s", err)
	}
	defer rows.Close()
	var events []*mms.ProductEvent
	for rows.Next() {
		var id int
		var createdAt string
		var payload []byte
		rows.Scan(&id, &createdAt, &payload)
		var event mms.ProductEvent
		if err := json.Unmarshal(payload, &event); err != nil {
			log.Printf("failed to unmarshal an event from db: %s", err)
		} else {
			events = append(events, &event)
		}
	}
	return events, nil
}
func ( service * Service ) GetAllEvents ( ctx context . Context ) ( [ ] * mms . ProductEvent , error ) { rows , err := service . eventsDB . QueryContext ( ctx , " " ) if err != nil { return nil , fmt . Errorf ( " " , err ) } defer rows . Close ( ) var events [ ] * mms . ProductEvent for rows . Next ( ) { var id int var createdAt string var payload [ ] byte rows . Scan ( & id , & createdAt , & payload ) var event mms . ProductEvent if err := json . Unmarshal ( payload , & event ) ; err != nil { log . Printf ( " " , err ) } else { events = append ( events , & event ) } } return events , nil }
GetAllEvents returns all product events in the events database.
GetAllEvents returns all product events in the events database .