func (q versionQuery) Count(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
	var count int64
	queries.SetSelect(q.Query, nil)
	queries.SetCount(q.Query)
	err := q.Query.QueryRowContext(ctx, exec).Scan(&count)
	if err != nil {
		return 0, fmt.Errorf("contenttype: failed to count dm_version rows: %w", err)
	}
	return count, nil
}
Count returns the count of all Version records in the query.
package contenttype
import (
	"context"
	"database/sql"
	"fmt"
	"reflect"
	"strconv"
	"strings"
	"sync"
	"time"
	"errors"
	"github.com/digimakergo/digimaker/core/db"
	. "github.com/digimakergo/digimaker/core/db"
	"github.com/volatiletech/sqlboiler/boil"
	"github.com/volatiletech/sqlboiler/queries"
	"github.com/volatiletech/sqlboiler/queries/qmhelper"
	"github.com/volatiletech/sqlboiler/strmangle"
)
type Version struct {
	ID          int    `boil:"id" json:"id" toml:"id" yaml:"id"`
	ContentType string `boil:"content_type" json:"content_type" toml:"content_type" yaml:"content_type"`
	ContentID   int    `boil:"content_id" json:"content_id" toml:"content_id" yaml:"content_id"`
	Version     int    `boil:"version" json:"version" toml:"version" yaml:"version"`
	Status      int8   `boil:"status" json:"status" toml:"status" yaml:"status"`
	Author      int    `boil:"author" json:"author" toml:"author" yaml:"author"`
	Data        string `boil:"data" json:"data" toml:"data" yaml:"data"`
	LocationID  int    `boil:"location_id" json:"location_id" toml:"location_id" yaml:"location_id"`
	Created     int    `boil:"created" json:"created" toml:"created" yaml:"created"`
	R        *versionR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L        versionL  `boil:"-" json:"-" toml:"-" yaml:"-"`
	Location `boil:"dm_location,bind"`
}
func (c *Version) ToMap() map[string]interface{} {
	result := make(map[string]interface{})
	result["id"] = c.ID
	result["content_type"] = c.ContentType
	result["content_id"] = c.ContentID
	result["version"] = c.Version
	result["status"] = c.Status
	result["author"] = c.Author
	result["data"] = c.Data
	result["location_id"] = c.LocationID
	result["created"] = c.Created
	return result
}
func (c *Version) TableName() string {
	return "dm_version"
}
func (c *Version) Field(name string) interface{} {
	var result interface{}
	switch name {
	case "id", "ID":
		result = c.ID
	case "content_type", "ContentType":
		result = c.ContentType
	case "content_id", "ContentID":
		result = c.ContentID
	case "version", "Version":
		result = c.Version
	case "status", "Status":
		result = c.Status
	case "author", "Author":
		result = c.Author
	case "data", "Data":
		result = c.Data
	case "location_id", "LocationID":
		result = c.LocationID
	case "created", "Created":
		result = c.Created
	default:
	}
	return result
}
func (c Version) Store(ctx context.Context, transaction ...*sql.Tx) error {
	if c.ID == 0 {
		id, err := db.Insert(ctx, c.TableName(), c.ToMap(), transaction...)
		c.ID = id
		if err != nil {
			return err
		}
	} else {
		err := db.Update(ctx, c.TableName(), c.ToMap(), Cond("id", c.ID), transaction...)
		return err
	}
	return nil
}
var VersionColumns = struct {
	ID          string
	ContentType string
	ContentID   string
	Version     string
	Status      string
	Author      string
	Data        string
	LocationID  string
	Created     string
}{
	ID:          "id",
	ContentType: "content_type",
	ContentID:   "content_id",
	Version:     "version",
	Status:      "status",
	Author:      "author",
	Data:        "data",
	LocationID:  "location_id",
	Created:     "created",
}
var VersionRels = struct {
}{}
type versionR struct {
}
func (*versionR) NewStruct() *versionR {
	return &versionR{}
}
type versionL struct{}
var (
	versionColumns               = []string{"id", "content_type", "content_id", "version", "status", "author", "data", "location_id", "created"}
	versionColumnsWithoutDefault = []string{"content_type", "content_id", "version", "data", "created"}
	versionColumnsWithDefault    = []string{"id", "status", "author", "location_id"}
	versionPrimaryKeyColumns     = []string{"id"}
)
type (
	VersionSlice []*Version
	VersionHook func(context.Context, boil.ContextExecutor, *Version) error
	versionQuery struct {
		*queries.Query
	}
)
var (
	versionType                 = reflect.TypeOf(&Version{})
	versionMapping              = queries.MakeStructMapping(versionType)
	versionPrimaryKeyMapping, _ = queries.BindMapping(versionType, versionMapping, versionPrimaryKeyColumns)
	versionInsertCacheMut       sync.RWMutex
	versionInsertCache          = make(map[string]insertCache)
	versionUpdateCacheMut       sync.RWMutex
	versionUpdateCache          = make(map[string]updateCache)
	versionUpsertCacheMut       sync.RWMutex
	versionUpsertCache          = make(map[string]insertCache)
)
var (
	_ = time.Second
	_ = qmhelper.Where
)
var versionBeforeInsertHooks []VersionHook
var versionBeforeUpdateHooks []VersionHook
var versionBeforeDeleteHooks []VersionHook
var versionBeforeUpsertHooks []VersionHook
var versionAfterInsertHooks []VersionHook
var versionAfterSelectHooks []VersionHook
var versionAfterUpdateHooks []VersionHook
var versionAfterDeleteHooks []VersionHook
var versionAfterUpsertHooks []VersionHook
func (o *Version) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range versionBeforeInsertHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Version) doBeforeUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range versionBeforeUpdateHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Version) doBeforeDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range versionBeforeDeleteHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Version) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range versionBeforeUpsertHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Version) doAfterInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range versionAfterInsertHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Version) doAfterSelectHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range versionAfterSelectHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Version) doAfterUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range versionAfterUpdateHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Version) doAfterDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range versionAfterDeleteHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func (o *Version) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {
	if boil.HooksAreSkipped(ctx) {
		return nil
	}
	for _, hook := range versionAfterUpsertHooks {
		if err := hook(ctx, exec, o); err != nil {
			return err
		}
	}
	return nil
}
func AddVersionHook(hookPoint boil.HookPoint, versionHook VersionHook) {
	switch hookPoint {
	case boil.BeforeInsertHook:
		versionBeforeInsertHooks = append(versionBeforeInsertHooks, versionHook)
	case boil.BeforeUpdateHook:
		versionBeforeUpdateHooks = append(versionBeforeUpdateHooks, versionHook)
	case boil.BeforeDeleteHook:
		versionBeforeDeleteHooks = append(versionBeforeDeleteHooks, versionHook)
	case boil.BeforeUpsertHook:
		versionBeforeUpsertHooks = append(versionBeforeUpsertHooks, versionHook)
	case boil.AfterInsertHook:
		versionAfterInsertHooks = append(versionAfterInsertHooks, versionHook)
	case boil.AfterSelectHook:
		versionAfterSelectHooks = append(versionAfterSelectHooks, versionHook)
	case boil.AfterUpdateHook:
		versionAfterUpdateHooks = append(versionAfterUpdateHooks, versionHook)
	case boil.AfterDeleteHook:
		versionAfterDeleteHooks = append(versionAfterDeleteHooks, versionHook)
	case boil.AfterUpsertHook:
		versionAfterUpsertHooks = append(versionAfterUpsertHooks, versionHook)
	}
}
func (q versionQuery) One(ctx context.Context, exec boil.ContextExecutor) (*Version, error) {
	o := &Version{}
	queries.SetLimit(q.Query, 1)
	err := q.Bind(ctx, exec, o)
	if err != nil {
		if errors.Is(err, sql.ErrNoRows) {
			return nil, sql.ErrNoRows
		}
		return nil, fmt.Errorf("contenttype: failed to execute a one query for dm_version: %w", err)
	}
	if err := o.doAfterSelectHooks(ctx, exec); err != nil {
		return o, err
	}
	return o, nil
}
func (q versionQuery) All(ctx context.Context, exec boil.ContextExecutor) (VersionSlice, error) {
	var o []*Version
	err := q.Bind(ctx, exec, &o)
	if err != nil {
		return nil, fmt.Errorf("contenttype: failed to assign all query results to Version slice: %w", err)
	}
	if len(versionAfterSelectHooks) != 0 {
		for _, obj := range o {
			if err := obj.doAfterSelectHooks(ctx, exec); err != nil {
				return o, err
			}
		}
	}
	return o, nil
}