From 322ef09c1f6afe0c0bc3bca45202c29548a56f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Fri, 2 Oct 2026 01:41:25 +0300 Subject: [PATCH] feat(storage/postgres): lab2 add Storage wrapper and interface assertions --- backend/internal/storage/postgres/storage.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 backend/internal/storage/postgres/storage.go diff --git a/backend/internal/storage/postgres/storage.go b/backend/internal/storage/postgres/storage.go new file mode 100644 index 0000000..110fef1 --- /dev/null +++ b/backend/internal/storage/postgres/storage.go @@ -0,0 +1,18 @@ +package postgres + +import "github.com/jackc/pgx/v5/pgxpool" + +type Storage struct { + pool *pgxpool.Pool +} + +func New(pool *pgxpool.Pool) *Storage { + return &Storage{pool: pool} +} + +func (s *Storage) Pool() *pgxpool.Pool { return s.pool } + +func (s *Storage) Users() *UserRepo { return &UserRepo{pool: s.pool} } +func (s *Storage) Chats() *ChatRepo { return &ChatRepo{pool: s.pool} } +func (s *Storage) Messages() *MessageRepo { return &MessageRepo{pool: s.pool} } +func (s *Storage) Sessions() *SessionRepo { return &SessionRepo{pool: s.pool} }