func AppendInt64(ctx context.Context, db generated.DB, name string, value interface{}, where generated.WhereClause) (int64, error) {
	idx := 2
	sqlstr := `UPDATE public.books SET ` +
		name + " = array_append(" + name + ", $1::bigint) " +
		` WHERE ` +
		where.String(&idx)
	res, err := db.ExecContext(ctx, sqlstr, append([]interface{}{value}, where.Values()...)...)
	if err != nil {
		return 0, errors.Wrap(err, "append_int64 Books")
	}
	return res.RowsAffected()
}
AppendInt64 adds a value to a field
package books
import (
	"context"
	"database/sql"
	"time"
	"github.com/Mattel/mcpp/data/gnorm"
	"github.com/gnormal/postgres-go/generated"
	"github.com/gnormal/postgres-go/generated/public/enum"
	uuid "github.com/gofrs/uuid"
	"github.com/pkg/errors"
)
const TableName = "books"
type Row struct {
	ID        int             
	AuthorID  uuid.UUID       
	Available time.Time       
	Booktype  enum.BookType   
	Isbn      string          
	Pages     int             
	Summary   sql.NullString  
	Title     string          
}
var (
	AuthorIDCol  generated.UuidUUIDField      = "author_id"
	AvailableCol generated.TimeTimeField      = "available"
	BooktypeCol  enum.BookTypeField           = "booktype"
	IDCol        generated.IntField           = "id"
	IsbnCol      generated.StringField        = "isbn"
	PagesCol     generated.IntField           = "pages"
	SummaryCol   generated.SqlNullStringField = "summary"
	TitleCol     generated.StringField        = "title"
)
func All(ctx context.Context, db generated.DB) ([]*Row, error) {
	const sqlstr = `SELECT
		author_id, available, booktype, id, isbn, pages, summary, title
		FROM public.books`
	var vals []*Row
	q, err := db.QueryContext(ctx, sqlstr)
	if err != nil {
		return nil, errors.Wrap(err, "query Books")
	}
	for q.Next() {
		r := Row{}
		err := q.Scan(&r.AuthorID,
			&r.Available,
			&r.Booktype,
			&r.ID,
			&r.Isbn,
			&r.Pages,
			&r.Summary,
			&r.Title,
		)
		if err != nil {
			return nil, errors.Wrap(err, "all Books")
		}
		vals = append(vals, &r)
	}
	return vals, nil
}
func CountQuery(ctx context.Context, db gnorm.DB, where gnorm.WhereClause) (int, error) {
	const origsqlstr = `SELECT
		count(*) as count
		FROM public.books WHERE (`
	idx := 1
	sqlstr := origsqlstr + where.String(&idx) + ") "
	count := 0
	err := db.QueryRowContext(ctx, sqlstr, where.Values()...).Scan(&count)
	if err != nil {
		return 0, errors.Wrap(err, "count Books")
	}
	return count, nil
}
func Query(ctx context.Context, db generated.DB, where generated.WhereClause) ([]*Row, error) {
	const origsqlstr = `SELECT
		id, author_id, isbn, booktype, title, pages, summary, available
		FROM public.books WHERE (`
	idx := 1
	sqlstr := origsqlstr + where.String(&idx) + ") "
	var vals []*Row
	q, err := db.QueryContext(ctx, sqlstr, where.Values()...)
	if err != nil {
		return nil, errors.Wrap(err, "query Books")
	}
	for q.Next() {
		r := Row{}
		err := q.Scan(&r.ID,
			&r.AuthorID,
			&r.Isbn,
			&r.Booktype,
			&r.Title,
			&r.Pages,
			&r.Summary,
			&r.Available,
		)
		if err != nil {
			return nil, errors.Wrap(err, "query Books")
		}
		vals = append(vals, &r)
	}
	return vals, nil
}
func QueryOrder(ctx context.Context, db generated.DB, where generated.WhereClause, orderby generated.OrderBy) ([]*Row, error) {
	const origsqlstr = `SELECT
		id, author_id, isbn, booktype, title, pages, summary, available
		FROM public.books WHERE (`
	idx := 1
	sqlstr := origsqlstr + where.String(&idx) + ") " + orderby.String()
	var vals []*Row
	q, err := db.QueryContext(ctx, sqlstr, where.Values()...)
	if err != nil {
		return nil, errors.Wrap(err, "query Books")
	}
	for q.Next() {
		r := Row{}
		err := q.Scan(&r.ID,
			&r.AuthorID,
			&r.Isbn,
			&r.Booktype,
			&r.Title,
			&r.Pages,
			&r.Summary,
			&r.Available,
		)
		if err != nil {
			return nil, errors.Wrap(err, "query Books")
		}
		vals = append(vals, &r)
	}
	return vals, nil
}
func One(ctx context.Context, db generated.DB, where generated.WhereClause) (*Row, error) {
	const origsqlstr = `SELECT
		id, author_id, isbn, booktype, title, pages, summary, available
		FROM public.books WHERE (`
	idx := 1
	sqlstr := origsqlstr + where.String(&idx) + ") "
	r := &Row{}
	err := db.QueryRowContext(ctx, sqlstr, where.Values()...).Scan(&r.ID,
		&r.AuthorID,
		&r.Isbn,
		&r.Booktype,
		&r.Title,
		&r.Pages,
		&r.Summary,
		&r.Available,
	)
	if err != nil {
		return nil, errors.Wrap(err, "queryOne Books")
	}
	return r, nil
}
func First(ctx context.Context, db generated.DB, where generated.WhereClause, orderby generated.OrderBy) (*Row, error) {
	const origsqlstr = `SELECT
		id, author_id, isbn, booktype, title, pages, summary, available
		FROM public.books WHERE (`
	idx := 1
	sqlstr := origsqlstr + where.String(&idx) + ") " + orderby.String()
	r := &Row{}
	err := db.QueryRowContext(ctx, sqlstr, where.Values()...).Scan(&r.ID,
		&r.AuthorID,
		&r.Isbn,
		&r.Booktype,
		&r.Title,
		&r.Pages,
		&r.Summary,
		&r.Available,
	)
	if err != nil {
		return nil, errors.Wrap(err, "queryFirst Books")
	}
	return r, nil
}
func Find(ctx context.Context, db generated.DB,
	id int,
) (*Row, error) {
	const sqlstr = `SELECT
		author_id, available, booktype, id, isbn, pages, summary, title
	FROM public.books WHERE ( id = $1 )`
	r := &Row{}
	err := db.QueryRowContext(ctx, sqlstr,
		id,
	).Scan(&r.AuthorID,
		&r.Available,
		&r.Booktype,
		&r.ID,
		&r.Isbn,
		&r.Pages,
		&r.Summary,
		&r.Title,
	)
	if err != nil {
		return nil, errors.Wrap(err, "find Books")
	}
	return r, nil
}
func Insert(ctx context.Context, db generated.DB, r *Row) error {
	const sqlstr = `INSERT INTO public.books ` +
		`(
			author_id, available, booktype, isbn, pages, summary, title
		) VALUES (
			$1, $2, $3, $4, $5, $6, $7
		) ` +
		`RETURNING
			created_at, id
		`
	err := db.QueryRowContext(ctx, sqlstr, &r.AuthorID,
		&r.Available,
		&r.Booktype,
		&r.Isbn,
		&r.Pages,
		&r.Summary,
		&r.Title,
	).Scan(&r.CreatedAt, &r.ID)
	return errors.Wrap(err, "insert Books")
}
func InsertIgnore(ctx context.Context, db gnorm.DB, r *Row, constraint string) error {
	sqlstr := `INSERT INTO public.books ` +
		`(
			author_id, available, booktype, isbn, pages, summary, title
		) VALUES (
			$1, $2, $3, $4, $5, $6, $7
		) ` +
		`ON CONFLICT ON CONSTRAINT ` + constraint + ` DO NOTHING `
	_, err := db.ExecContext(ctx, sqlstr, r.AuthorID, r.Available, r.Booktype, r.Isbn, r.Pages, r.Summary, r.Title)
	return errors.Wrap(err, "insert ignore Books")
}
func Set(ctx context.Context, db generated.DB, set generated.Where, where generated.WhereClause) (int64, error) {
	idx := 2
	sqlstr := `UPDATE public.books SET ` +
		set.Field + " = $1 " +
		` WHERE ` +
		where.String(&idx)
	res, err := db.ExecContext(ctx, sqlstr, append([]interface{}{set.Value}, where.Values()...)...)
	if err != nil {
		return 0, errors.Wrap(err, "set Books")
	}
	return res.RowsAffected()
}