// Package store builds the per-domain metadata repositories for a chosen // backend. Domains depend on their Repository interfaces; this factory is the // single place that knows the concrete implementations. package store import ( "database/sql" "github.com/jackc/pgx/v5/pgxpool" "shared-album/internal/albums" "shared-album/internal/auth" "shared-album/internal/members" "shared-album/internal/notifications" "shared-album/internal/photos" "shared-album/internal/settings" "shared-album/internal/sharelinks" "shared-album/internal/social" ) // Repos bundles one repository per domain. type Repos struct { Auth auth.Repository Albums albums.Repository Members members.Repository Photos photos.Repository Social social.Repository Notifications notifications.Repository ShareLinks sharelinks.Repository Settings settings.Repository } // NewPostgres builds the repositories backed by PostgreSQL. func NewPostgres(pool *pgxpool.Pool) Repos { return Repos{ Auth: auth.NewStore(pool), Albums: albums.NewStore(pool), Members: members.NewStore(pool), Photos: photos.NewStore(pool), Social: social.NewStore(pool), Notifications: notifications.NewStore(pool), ShareLinks: sharelinks.NewStore(pool), Settings: settings.NewStore(pool), } } // NewSQLite builds the repositories backed by SQLite. func NewSQLite(db *sql.DB) Repos { return Repos{ Auth: auth.NewSQLiteStore(db), Albums: albums.NewSQLiteStore(db), Members: members.NewSQLiteStore(db), Photos: photos.NewSQLiteStore(db), Social: social.NewSQLiteStore(db), Notifications: notifications.NewSQLiteStore(db), ShareLinks: sharelinks.NewSQLiteStore(db), Settings: settings.NewSQLiteStore(db), } }