func (p *FuncProvider) ReadRecord(_ *record.Person, id idgen.Generator, _ *rand.Rand) bool {
	recordID := id.GetExisting()
	var rawData []byte
	err := p.DB.QueryRow("SELECT data FROM "+p.TableName+" WHERE data->'id'=$1", recordID).Scan(&rawData)
	if err != nil {
		log.Println(recordID, err)
		return false
	}
	var data = &record.Person{}
	if err := json.Unmarshal(rawData, &data); err != nil {
		log.Println(recordID, err)
		return false
	}
	return true
}
ReadRecord attempts to fetch the record with an ID returned by
id.GetExisting.
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
}
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
}