This commit is contained in:
2025-11-12 09:41:52 +03:00
commit 2a8566712a
44 changed files with 2602 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package storage
import (
"context"
"fmt"
"github.com/jackc/pgx/v5"
"madsky.ru/go-tracker/internal/database"
)
type UserToProjectRepository interface {
Create(ctx context.Context, userId uint32, projectId uint32) error
}
type UserToProjectStore struct {
client database.Client
}
func (up *UserToProjectStore) Create(ctx context.Context, userId uint32, projectId uint32) error {
query := `insert into user_to_project (user_id, project_id) values (@userId, @projectId)`
args := pgx.NamedArgs{
"userId": userId,
"projectId": projectId,
}
_, err := up.client.Exec(ctx, query, args)
if err != nil {
return fmt.Errorf("unable to insert row: %w", err)
}
return nil
}