Documentation
¶
Index ¶
- Variables
- type Event
- type EventModel
- func (m *EventModel) Create(title, description string, eventDate time.Time, location string) (int, error)
- func (m *EventModel) Delete(id int) error
- func (m *EventModel) List() ([]Event, error)
- func (m *EventModel) Retrieve(id int) (Event, error)
- func (m *EventModel) Update(id int, title, description string, eventDate time.Time, location string) error
- type User
- type UserModel
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoRecord indicates that no matching record was found in the database or data source. ErrNoRecord = errors.New("models: no matching record found") // ErrInvalidCredentials indicates that the provided user credentials are // invalid or do not match any record in the system. ErrInvalidCredentials = errors.New("models: invalid credentials") // ErrDuplicateEmail indicates that the provided email already exists // in the system and cannot be used again. ErrDuplicateEmail = errors.New("models: duplicate email") )
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Id int
Title string
Description string
Location string
EventDate time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
Event represents a scheduled occurrence with a title, description, date, and location.
type EventModel ¶
EventModel provides methods for managing and interacting with events in the database. It includes functionality to create, retrieve, and list event records. The `DB` field holds the database connection used for queries and operations.
func (*EventModel) Create ¶
func (m *EventModel) Create(title, description string, eventDate time.Time, location string) (int, error)
Create adds a new event record to the database with the provided title, description, date, and location. It returns the ID of the newly created event or an error if the operation fails.
func (*EventModel) Delete ¶
func (m *EventModel) Delete(id int) error
Delete removes an event record from the database by its unique ID and returns an error if the operation fails.
func (*EventModel) List ¶
func (m *EventModel) List() ([]Event, error)
List retrieves all event records from the database and returns them as a slice of Event pointers or an error if it fails.
func (*EventModel) Retrieve ¶
func (m *EventModel) Retrieve(id int) (Event, error)
Retrieve retrieves an event from the database by its unique ID. It returns the matching Event object or an error if the query fails or no event is found.
func (*EventModel) Update ¶
func (m *EventModel) Update(id int, title, description string, eventDate time.Time, location string) error
Update modifies an existing event in the database using the provided ID and updated event details. Returns an error if the update operation fails or if no record is affected.
type UserModel ¶
UserModel provides methods to interact with the users' data in the database using an sql.DB instance.
func (*UserModel) Authenticate ¶
Authenticate verifies a user's credentials and returns their ID if valid or an error if authentication fails.