func (p *FuncProvider) UpdateRecord(_ *record.Person, id idgen.Generator, rnd *rand.Rand) bool {
	recordID := id.GetExisting()
	_, err := p.DB.Exec(
		"UPDATE "+p.TableName+" SET data=jsonb_set(data, '{balance}', $1::jsonb, false) where data->'id'=$2;",
		strconv.FormatFloat(float64(rnd.Float32()), 'f', -1, 32),
		recordID,
	)
	if err != nil {
		log.Println(recordID, err)
		return false
	}
	return true
}
UpdateRecord attempts to update the record with ID returned by
id.GetExisting.

The balance field is changed to a random value from rnd using jsonb_set.
package postgres
import (
	"database/sql"
	"encoding/json"
	"fmt"
	"log"
	"math/rand"
	"net/url"
	"runtime"
	"strconv"
	"github.com/domodwyer/mpjbt/idgen"
	"github.com/domodwyer/mpjbt/record"
	_ "github.com/lib/pq"
)
type FuncProvider struct {
	DB        *sql.DB
	TableName string
}
func (p *FuncProvider) InsertRecord(data *record.Person, id idgen.Generator, rnd *rand.Rand) bool {
	data.Randomise(rnd)
	data.ID = id.GetNew()
	jsonData, err := json.Marshal(data)
	if err != nil {
		panic(err)
	}
	_, err = p.DB.Exec("INSERT INTO "+p.TableName+" (data) VALUES ($1)", string(jsonData))
	if err != nil {
		log.Println(err)
		return false
	}
	return true
}