package repository import ( "context" "encoding/json" "github.com/google/uuid" "github.com/jackc/pgx/v5/pgxpool" "github.com/yuxingu/digital-psychology/apps/api/internal/model" ) // RelationRepo persists relation insights. type RelationRepo struct { Pool *pgxpool.Pool } // Create inserts a relation insight row. func (r *RelationRepo) Create(ctx context.Context, userID, aID, bID uuid.UUID, summary json.RawMessage, reportID uuid.UUID) (*model.RelationInsight, error) { row := &model.RelationInsight{} err := r.Pool.QueryRow(ctx, ` INSERT INTO relation_insights(user_id, profile_a_id, profile_b_id, summary, report_id) VALUES ($1,$2,$3,$4,$5) RETURNING id, user_id, profile_a_id, profile_b_id, summary, report_id, created_at`, userID, aID, bID, summary, reportID, ).Scan(&row.ID, &row.UserID, &row.ProfileAID, &row.ProfileBID, &row.Summary, &row.ReportID, &row.CreatedAt) return row, err }