func (repo *PostgresRepository) QueryInTx(ctx context.Context, tx nero.Tx, q *Queryer) ([]*player.Player, error) {
	txx, ok := tx.(*sql.Tx)
	if !ok {
		return nil, errors.New("expecting tx to be *sql.Tx")
	}
	return repo.query(ctx, txx, q)
}
QueryInTx queries Players in a transaction
package playerrepo
import (
	"context"
	"database/sql"
	"fmt"
	"log"
	"os"
	"reflect"
	"strings"
	"github.com/Masterminds/squirrel"
	"github.com/pkg/errors"
	"github.com/sf9v/nero"
	"github.com/sf9v/nero/aggregate"
	"github.com/sf9v/nero/comparison"
	"github.com/sf9v/nero/sort"
	"github.com/sf9v/nero/test/integration/player"
)
type PostgresRepository struct {
	db     *sql.DB
	logger nero.Logger
	debug  bool
}
var _ Repository = (*PostgresRepository)(nil)
func NewPostgresRepository(db *sql.DB) *PostgresRepository {
	return &PostgresRepository{db: db}
}
func (repo *PostgresRepository) Debug() *PostgresRepository {
	l := log.New(os.Stdout, "[nero] ", log.LstdFlags|log.Lmicroseconds|log.Lmsgprefix)
	return &PostgresRepository{
		db:     repo.db,
		debug:  true,
		logger: l,
	}
}
func (repo *PostgresRepository) WithLogger(logger nero.Logger) *PostgresRepository {
	repo.logger = logger
	return repo
}
func (repo *PostgresRepository) BeginTx(ctx context.Context) (nero.Tx, error) {
	return repo.db.BeginTx(ctx, nil)
}
func (repo *PostgresRepository) Create(ctx context.Context, c *Creator) (string, error) {
	return repo.create(ctx, repo.db, c)
}
func (repo *PostgresRepository) CreateInTx(ctx context.Context, tx nero.Tx, c *Creator) (string, error) {
	txx, ok := tx.(*sql.Tx)
	if !ok {
		return "", errors.New("expecting tx to be *sql.Tx")
	}
	return repo.create(ctx, txx, c)
}
func (repo *PostgresRepository) create(ctx context.Context, runner nero.SQLRunner, c *Creator) (string, error) {
	if err := c.Validate(); err != nil {
		return "", err
	}
	columns := []string{
		"\"email\"",
		"\"name\"",
		"\"age\"",
		"\"race\"",
	}
	values := []interface{}{
		c.email,
		c.name,
		c.age,
		c.race,
	}
	if !isZero(c.updatedAt) {
		columns = append(columns, "updated_at")
		values = append(values, c.updatedAt)
	}
	qb := squirrel.Insert("\"players\"").
		Columns(columns...).
		Values(values...).
		Suffix("RETURNING \"id\"").
		PlaceholderFormat(squirrel.Dollar).
		RunWith(runner)
	if repo.debug && repo.logger != nil {
		sql, args, err := qb.ToSql()
		repo.logger.Printf("method: Create, stmt: %q, args: %v, error: %v", sql, args, err)
	}
	var id string
	err := qb.QueryRowContext(ctx).Scan(&id)
	if err != nil {
		return "", err
	}
	return id, nil
}
func (repo *PostgresRepository) CreateMany(ctx context.Context, cs ...*Creator) error {
	return repo.createMany(ctx, repo.db, cs...)
}
func (repo *PostgresRepository) CreateManyInTx(ctx context.Context, tx nero.Tx, cs ...*Creator) error {
	txx, ok := tx.(*sql.Tx)
	if !ok {
		return errors.New("expecting tx to be *sql.Tx")
	}
	return repo.createMany(ctx, txx, cs...)
}
func (repo *PostgresRepository) createMany(ctx context.Context, runner nero.SQLRunner, cs ...*Creator) error {
	if len(cs) == 0 {
		return nil
	}
	columns := []string{
		"\"email\"",
		"\"name\"",
		"\"age\"",
		"\"race\"",
		"\"updated_at\"",
	}
	qb := squirrel.Insert("\"players\"").Columns(columns...)
	for _, c := range cs {
		if err := c.Validate(); err != nil {
			return err
		}
		qb = qb.Values(
			c.email,
			c.name,
			c.age,
			c.race,
			c.updatedAt,
		)
	}
	qb = qb.Suffix("RETURNING \"id\"").
		PlaceholderFormat(squirrel.Dollar)
	if repo.debug && repo.logger != nil {
		sql, args, err := qb.ToSql()
		repo.logger.Printf("method: CreateMany, stmt: %q, args: %v, error: %v", sql, args, err)
	}
	_, err := qb.RunWith(runner).ExecContext(ctx)
	if err != nil {
		return err
	}
	return nil
}
func (repo *PostgresRepository) Query(ctx context.Context, q *Queryer) ([]*player.Player, error) {
	return repo.query(ctx, repo.db, q)
}