Files
greenlight/internal/data/models.go
Maxime Delporte f8f78c3eec
All checks were successful
Deploy Greenlight API / deploy (push) Successful in 57s
Adding concurrency control in our updateMovieHandler and documenting it.
2025-11-08 10:41:44 +01:00

26 lines
757 B
Go

package data
import (
"database/sql"
"errors"
)
// ErrRecordNotFound : Define a custom ErrRecordNotFound error. We'll return this from our Get() method when looking up a movie that doesn't exist in our database.
// ErrEditConflict : This error is used when a data race occurs.
var (
ErrRecordNotFound = errors.New("record not found")
ErrEditConflict = errors.New("edit conflict")
)
// Models : Wraps the MovieModel. We'll add other models to this, like a UserModel and PermissionModel, as our build progresses.
type Models struct {
Movies MovieModel
}
// NewModels : For ease of use, this method returns a Models struct containing the initialized MovieModel.
func NewModels(db *sql.DB) Models {
return Models{
Movies: MovieModel{DB: db},
}
}