feat: sql, migrations, sql postgress db setup, movie model

This commit is contained in:
2026-03-13 13:19:55 +01:00
parent 92295654e7
commit bf1c306ef7
14 changed files with 148 additions and 13 deletions
@@ -0,0 +1,27 @@
package data
import (
"database/sql"
"errors"
)
// 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.
var (
ErrRecordNotFound = errors.New("record not found")
)
// Create a Models struct which wraps the MovieModel. We'll add other models to this,
// like a UserModel and PermissionModel, as our build progresses.
type Models struct {
Movies MovieModel
}
// For ease of use, we also add a New()
// method which returns a Models struct containing
// the initialized MovieModel.
func NewModels(db *sql.DB) Models {
return Models{
Movies: MovieModel{DB: db},
}
}