// 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 backupLocationTableType struct {
	s parse.StructInfo
	z []interface{}
}

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

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

// Columns returns a new slice of column names for that view or table in SQL database.
func (v *backupLocationTableType) Columns() []string {
	return []string{
		"id",
		"name",
		"description",
		"type",
		"s3_config",
		"pmm_server_config",
		"pmm_client_config",
		"created_at",
		"updated_at",
	}
}

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

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

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

// BackupLocationTable represents backup_locations view or table in SQL database.
var BackupLocationTable = &backupLocationTableType{
	s: parse.StructInfo{
		Type:    "BackupLocation",
		SQLName: "backup_locations",
		Fields: []parse.FieldInfo{
			{Name: "ID", Type: "string", Column: "id"},
			{Name: "Name", Type: "string", Column: "name"},
			{Name: "Description", Type: "string", Column: "description"},
			{Name: "Type", Type: "BackupLocationType", Column: "type"},
			{Name: "S3Config", Type: "*S3LocationConfig", Column: "s3_config"},
			{Name: "PMMServerConfig", Type: "*PMMServerLocationConfig", Column: "pmm_server_config"},
			{Name: "PMMClientConfig", Type: "*PMMClientLocationConfig", Column: "pmm_client_config"},
			{Name: "CreatedAt", Type: "time.Time", Column: "created_at"},
			{Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"},
		},
		PKFieldIndex: 0,
	},
	z: new(BackupLocation).Values(),
}

// String returns a string representation of this struct or record.
func (s BackupLocation) String() string {
	res := make([]string, 9)
	res[0] = "ID: " + reform.Inspect(s.ID, true)
	res[1] = "Name: " + reform.Inspect(s.Name, true)
	res[2] = "Description: " + reform.Inspect(s.Description, true)
	res[3] = "Type: " + reform.Inspect(s.Type, true)
	res[4] = "S3Config: " + reform.Inspect(s.S3Config, true)
	res[5] = "PMMServerConfig: " + reform.Inspect(s.PMMServerConfig, true)
	res[6] = "PMMClientConfig: " + reform.Inspect(s.PMMClientConfig, true)
	res[7] = "CreatedAt: " + reform.Inspect(s.CreatedAt, true)
	res[8] = "UpdatedAt: " + reform.Inspect(s.UpdatedAt, true)
	return strings.Join(res, ", ")
}

// Values returns a slice of struct or record field values.
// Returned interface{} values are never untyped nils.
func (s *BackupLocation) Values() []interface{} {
	return []interface{}{
		s.ID,
		s.Name,
		s.Description,
		s.Type,
		s.S3Config,
		s.PMMServerConfig,
		s.PMMClientConfig,
		s.CreatedAt,
		s.UpdatedAt,
	}
}

// Pointers returns a slice of pointers to struct or record fields.
// Returned interface{} values are never untyped nils.
func (s *BackupLocation) Pointers() []interface{} {
	return []interface{}{
		&s.ID,
		&s.Name,
		&s.Description,
		&s.Type,
		&s.S3Config,
		&s.PMMServerConfig,
		&s.PMMClientConfig,
		&s.CreatedAt,
		&s.UpdatedAt,
	}
}

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

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

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

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

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

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

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

func init() {
	parse.AssertUpToDate(&BackupLocationTable.s, new(BackupLocation))
}
