// Code generated by gopkg.in/reform.v1. DO NOT EDIT.

package models

import (
	"fmt"
	"strings"

	"gopkg.in/reform.v1"
	"gopkg.in/reform.v1/parse"
)

type serviceTableType struct {
	s parse.StructInfo
	z []interface{}
}

// Schema returns a schema name in SQL database ("").
func (v *serviceTableType) Schema() string {
	return v.s.SQLSchema
}

// Name returns a view or table name in SQL database ("services").
func (v *serviceTableType) Name() string {
	return v.s.SQLName
}

// Columns returns a new slice of column names for that view or table in SQL database.
func (v *serviceTableType) Columns() []string {
	return []string{
		"service_id",
		"service_type",
		"service_name",
		"database_name",
		"node_id",
		"environment",
		"cluster",
		"replication_set",
		"custom_labels",
		"external_group",
		"created_at",
		"updated_at",
		"address",
		"port",
		"socket",
	}
}

// NewStruct makes a new struct for that view or table.
func (v *serviceTableType) NewStruct() reform.Struct {
	return new(Service)
}

// NewRecord makes a new record for that table.
func (v *serviceTableType) NewRecord() reform.Record {
	return new(Service)
}

// PKColumnIndex returns an index of primary key column for that table in SQL database.
func (v *serviceTableType) PKColumnIndex() uint {
	return uint(v.s.PKFieldIndex)
}

// ServiceTable represents services view or table in SQL database.
var ServiceTable = &serviceTableType{
	s: parse.StructInfo{
		Type:    "Service",
		SQLName: "services",
		Fields: []parse.FieldInfo{
			{Name: "ServiceID", Type: "string", Column: "service_id"},
			{Name: "ServiceType", Type: "ServiceType", Column: "service_type"},
			{Name: "ServiceName", Type: "string", Column: "service_name"},
			{Name: "DatabaseName", Type: "string", Column: "database_name"},
			{Name: "NodeID", Type: "string", Column: "node_id"},
			{Name: "Environment", Type: "string", Column: "environment"},
			{Name: "Cluster", Type: "string", Column: "cluster"},
			{Name: "ReplicationSet", Type: "string", Column: "replication_set"},
			{Name: "CustomLabels", Type: "[]uint8", Column: "custom_labels"},
			{Name: "ExternalGroup", Type: "string", Column: "external_group"},
			{Name: "CreatedAt", Type: "time.Time", Column: "created_at"},
			{Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"},
			{Name: "Address", Type: "*string", Column: "address"},
			{Name: "Port", Type: "*uint16", Column: "port"},
			{Name: "Socket", Type: "*string", Column: "socket"},
		},
		PKFieldIndex: 0,
	},
	z: new(Service).Values(),
}

// String returns a string representation of this struct or record.
func (s Service) String() string {
	res := make([]string, 15)
	res[0] = "ServiceID: " + reform.Inspect(s.ServiceID, true)
	res[1] = "ServiceType: " + reform.Inspect(s.ServiceType, true)
	res[2] = "ServiceName: " + reform.Inspect(s.ServiceName, true)
	res[3] = "DatabaseName: " + reform.Inspect(s.DatabaseName, true)
	res[4] = "NodeID: " + reform.Inspect(s.NodeID, true)
	res[5] = "Environment: " + reform.Inspect(s.Environment, true)
	res[6] = "Cluster: " + reform.Inspect(s.Cluster, true)
	res[7] = "ReplicationSet: " + reform.Inspect(s.ReplicationSet, true)
	res[8] = "CustomLabels: " + reform.Inspect(s.CustomLabels, true)
	res[9] = "ExternalGroup: " + reform.Inspect(s.ExternalGroup, true)
	res[10] = "CreatedAt: " + reform.Inspect(s.CreatedAt, true)
	res[11] = "UpdatedAt: " + reform.Inspect(s.UpdatedAt, true)
	res[12] = "Address: " + reform.Inspect(s.Address, true)
	res[13] = "Port: " + reform.Inspect(s.Port, true)
	res[14] = "Socket: " + reform.Inspect(s.Socket, true)
	return strings.Join(res, ", ")
}

// Values returns a slice of struct or record field values.
// Returned interface{} values are never untyped nils.
func (s *Service) Values() []interface{} {
	return []interface{}{
		s.ServiceID,
		s.ServiceType,
		s.ServiceName,
		s.DatabaseName,
		s.NodeID,
		s.Environment,
		s.Cluster,
		s.ReplicationSet,
		s.CustomLabels,
		s.ExternalGroup,
		s.CreatedAt,
		s.UpdatedAt,
		s.Address,
		s.Port,
		s.Socket,
	}
}

// Pointers returns a slice of pointers to struct or record fields.
// Returned interface{} values are never untyped nils.
func (s *Service) Pointers() []interface{} {
	return []interface{}{
		&s.ServiceID,
		&s.ServiceType,
		&s.ServiceName,
		&s.DatabaseName,
		&s.NodeID,
		&s.Environment,
		&s.Cluster,
		&s.ReplicationSet,
		&s.CustomLabels,
		&s.ExternalGroup,
		&s.CreatedAt,
		&s.UpdatedAt,
		&s.Address,
		&s.Port,
		&s.Socket,
	}
}

// View returns View object for that struct.
func (s *Service) View() reform.View {
	return ServiceTable
}

// Table returns Table object for that record.
func (s *Service) Table() reform.Table {
	return ServiceTable
}

// PKValue returns a value of primary key for that record.
// Returned interface{} value is never untyped nil.
func (s *Service) PKValue() interface{} {
	return s.ServiceID
}

// PKPointer returns a pointer to primary key field for that record.
// Returned interface{} value is never untyped nil.
func (s *Service) PKPointer() interface{} {
	return &s.ServiceID
}

// HasPK returns true if record has non-zero primary key set, false otherwise.
func (s *Service) HasPK() bool {
	return s.ServiceID != ServiceTable.z[ServiceTable.s.PKFieldIndex]
}

// SetPK sets record primary key, if possible.
//
// Deprecated: prefer direct field assignment where possible: s.ServiceID = pk.
func (s *Service) SetPK(pk interface{}) {
	reform.SetPK(s, pk)
}

// check interfaces
var (
	_ reform.View   = ServiceTable
	_ reform.Struct = (*Service)(nil)
	_ reform.Table  = ServiceTable
	_ reform.Record = (*Service)(nil)
	_ fmt.Stringer  = (*Service)(nil)
)

func init() {
	parse.AssertUpToDate(&ServiceTable.s, new(Service))
}
