package postgres import ( "context" "database/sql" "time" "github.com/lib/pq" "midnadimple.com/fog/internal/store" ) type UsersStore struct { DB *sql.DB } func (s *UsersStore) Create(ctx context.Context, user *store.User) error { query := ` INSERT INTO users (username, password, email) VALUES($1, $2, $3) RETURNING id, created_at ` var createdAtStr string err := s.DB.QueryRowContext( ctx, query, user.Username, user.Password, user.Email, ).Scan( &user.ID, &createdAtStr, ) if err != nil { return err } user.CreatedAt, err = pq.ParseTimestamp(time.UTC, createdAtStr) if err != nil { return err } return nil }