models

package
v0.3.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DogIdFieldIndex            int = 0
	DogBreedFieldIndex         int = 1
	DogSizeFieldIndex          int = 2
	DogAgeInDogYearsFieldIndex int = 3
	DogMaxFieldIndex           int = (4 - 1)
)

bit indicies for 'fieldMask' parameters

Variables

A field set saying that all fields in Dog should be updated. For use as a 'fieldMask' parameter

View Source
var DogAllIncludes *include.Spec = include.Must(include.Parse(
	`dogs`,
))

Functions

This section is empty.

Types

type ConnPGClient

type ConnPGClient struct {
	// contains filtered or unexported fields
}

func (*ConnPGClient) BulkDeleteDog

func (conn *ConnPGClient) BulkDeleteDog(
	ctx context.Context,
	ids []int64,
	opts ...pggen.DeleteOpt,
) error

func (*ConnPGClient) BulkInsertDog

func (conn *ConnPGClient) BulkInsertDog(
	ctx context.Context,
	values []Dog,
	opts ...pggen.InsertOpt,
) ([]int64, error)

Insert a list of Dog. Returns a list of the primary keys of the inserted rows.

func (*ConnPGClient) BulkUpsertDog

func (conn *ConnPGClient) BulkUpsertDog(
	ctx context.Context,
	values []Dog,
	constraintNames []string,
	fieldMask pggen.FieldSet,
	opts ...pggen.UpsertOpt,
) (ret []int64, err error)

Upsert a set of Dog values. If any of the given values conflict with existing rows in the database, use the provided values to update the rows which exist in the database rather than inserting them. Only the fields specified by 'fieldMask' are actually updated. All other fields are left as-is.

func (*ConnPGClient) Close

func (conn *ConnPGClient) Close() error

func (*ConnPGClient) DeleteDog

func (conn *ConnPGClient) DeleteDog(
	ctx context.Context,
	id int64,
	opts ...pggen.DeleteOpt,
) error

func (*ConnPGClient) DogBulkFillIncludes

func (conn *ConnPGClient) DogBulkFillIncludes(
	ctx context.Context,
	recs []*Dog,
	includes *include.Spec,
	opts ...pggen.IncludeOpt,
) error

func (*ConnPGClient) DogFillIncludes

func (conn *ConnPGClient) DogFillIncludes(
	ctx context.Context,
	rec *Dog,
	includes *include.Spec,
	opts ...pggen.IncludeOpt,
) error

func (*ConnPGClient) GetDog

func (conn *ConnPGClient) GetDog(
	ctx context.Context,
	id int64,
	opts ...pggen.GetOpt,
) (*Dog, error)

func (*ConnPGClient) Handle

func (conn *ConnPGClient) Handle() pggen.DBHandle

func (*ConnPGClient) InsertDog

func (conn *ConnPGClient) InsertDog(
	ctx context.Context,
	value *Dog,
	opts ...pggen.InsertOpt,
) (ret int64, err error)

Insert a Dog into the database. Returns the primary key of the inserted row.

func (*ConnPGClient) ListDog

func (conn *ConnPGClient) ListDog(
	ctx context.Context,
	ids []int64,
	opts ...pggen.ListOpt,
) (ret []Dog, err error)

func (*ConnPGClient) UpdateDog

func (conn *ConnPGClient) UpdateDog(
	ctx context.Context,
	value *Dog,
	fieldMask pggen.FieldSet,
	opts ...pggen.UpdateOpt,
) (ret int64, err error)

Update a Dog. 'value' must at the least have a primary key set. The 'fieldMask' field set indicates which fields should be updated in the database.

Returns the primary key of the updated row.

func (*ConnPGClient) UpsertDog

func (conn *ConnPGClient) UpsertDog(
	ctx context.Context,
	value *Dog,
	constraintNames []string,
	fieldMask pggen.FieldSet,
	opts ...pggen.UpsertOpt,
) (ret int64, err error)

Upsert a Dog value. If the given value conflicts with an existing row in the database, use the provided value to update that row rather than inserting it. Only the fields specified by 'fieldMask' are actually updated. All other fields are left as-is.

type DBQueries

type DBQueries interface {

	// Dog methods
	GetDog(ctx context.Context, id int64, opts ...pggen.GetOpt) (*Dog, error)
	ListDog(ctx context.Context, ids []int64, opts ...pggen.ListOpt) ([]Dog, error)
	InsertDog(ctx context.Context, value *Dog, opts ...pggen.InsertOpt) (int64, error)
	BulkInsertDog(ctx context.Context, values []Dog, opts ...pggen.InsertOpt) ([]int64, error)
	UpdateDog(ctx context.Context, value *Dog, fieldMask pggen.FieldSet, opts ...pggen.UpdateOpt) (ret int64, err error)
	UpsertDog(ctx context.Context, value *Dog, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) (int64, error)
	BulkUpsertDog(ctx context.Context, values []Dog, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) ([]int64, error)
	DeleteDog(ctx context.Context, id int64, opts ...pggen.DeleteOpt) error
	BulkDeleteDog(ctx context.Context, ids []int64, opts ...pggen.DeleteOpt) error
	DogFillIncludes(ctx context.Context, rec *Dog, includes *include.Spec, opts ...pggen.IncludeOpt) error
	DogBulkFillIncludes(ctx context.Context, recs []*Dog, includes *include.Spec, opts ...pggen.IncludeOpt) error
}

type Dog

type Dog struct {
	Id            int64        `gorm:"column:id;is_primary"`
	Breed         string       `gorm:"column:breed"`
	Size          SizeCategory `gorm:"column:size"`
	AgeInDogYears int64        `gorm:"column:age_in_dog_years"`
}

func (*Dog) Bark

func (d *Dog) Bark() string

func (*Dog) Scan

func (r *Dog) Scan(ctx context.Context, client *PGClient, rs *sql.Rows) error

type NullSizeCategory

type NullSizeCategory struct {
	SizeCategory SizeCategory
	Valid        bool
}

func (*NullSizeCategory) Scan

func (n *NullSizeCategory) Scan(value interface{}) error

Scan implements the sql.Scanner interface

func (NullSizeCategory) Value

func (n NullSizeCategory) Value() (driver.Value, error)

Value implements the sql.Valuer interface

type PGClient

type PGClient struct {
	// contains filtered or unexported fields
}

PGClient wraps either a 'sql.DB' or a 'sql.Tx'. All pggen-generated database access methods for this package are attached to it.

func NewPGClient

func NewPGClient(conn pggen.DBConn) *PGClient

NewPGClient creates a new PGClient out of a '*sql.DB' or a custom wrapper around a db connection.

If you provide your own wrapper around a '*sql.DB' for logging or custom tracing, you MUST forward all calls to an underlying '*sql.DB' member of your wrapper.

If the DBConn passed into NewPGClient implements an ErrorConverter method which returns a func(error) error, the result of calling the ErrorConverter method will be called on every error that the generated code returns right before the error is returned. If ErrorConverter returns nil or is not present, it will default to the identity function.

func (*PGClient) BeginTx

func (p *PGClient) BeginTx(ctx context.Context, opts *sql.TxOptions) (*TxPGClient, error)

func (*PGClient) BulkDeleteDog

func (p *PGClient) BulkDeleteDog(
	ctx context.Context,
	ids []int64,
	opts ...pggen.DeleteOpt,
) error

func (*PGClient) BulkInsertDog

func (p *PGClient) BulkInsertDog(
	ctx context.Context,
	values []Dog,
	opts ...pggen.InsertOpt,
) ([]int64, error)

Insert a list of Dog. Returns a list of the primary keys of the inserted rows.

func (*PGClient) BulkUpsertDog

func (p *PGClient) BulkUpsertDog(
	ctx context.Context,
	values []Dog,
	constraintNames []string,
	fieldMask pggen.FieldSet,
	opts ...pggen.UpsertOpt,
) (ret []int64, err error)

Upsert a set of Dog values. If any of the given values conflict with existing rows in the database, use the provided values to update the rows which exist in the database rather than inserting them. Only the fields specified by 'fieldMask' are actually updated. All other fields are left as-is.

func (*PGClient) Conn

func (p *PGClient) Conn(ctx context.Context) (*ConnPGClient, error)

func (*PGClient) DeleteDog

func (p *PGClient) DeleteDog(
	ctx context.Context,
	id int64,
	opts ...pggen.DeleteOpt,
) error

func (*PGClient) DogBulkFillIncludes

func (p *PGClient) DogBulkFillIncludes(
	ctx context.Context,
	recs []*Dog,
	includes *include.Spec,
	opts ...pggen.IncludeOpt,
) error

func (*PGClient) DogFillIncludes

func (p *PGClient) DogFillIncludes(
	ctx context.Context,
	rec *Dog,
	includes *include.Spec,
	opts ...pggen.IncludeOpt,
) error

func (*PGClient) GetDog

func (p *PGClient) GetDog(
	ctx context.Context,
	id int64,
	opts ...pggen.GetOpt,
) (*Dog, error)

func (*PGClient) Handle

func (p *PGClient) Handle() pggen.DBHandle

func (*PGClient) InsertDog

func (p *PGClient) InsertDog(
	ctx context.Context,
	value *Dog,
	opts ...pggen.InsertOpt,
) (ret int64, err error)

Insert a Dog into the database. Returns the primary key of the inserted row.

func (*PGClient) ListDog

func (p *PGClient) ListDog(
	ctx context.Context,
	ids []int64,
	opts ...pggen.ListOpt,
) (ret []Dog, err error)

func (*PGClient) UpdateDog

func (p *PGClient) UpdateDog(
	ctx context.Context,
	value *Dog,
	fieldMask pggen.FieldSet,
	opts ...pggen.UpdateOpt,
) (ret int64, err error)

Update a Dog. 'value' must at the least have a primary key set. The 'fieldMask' field set indicates which fields should be updated in the database.

Returns the primary key of the updated row.

func (*PGClient) UpsertDog

func (p *PGClient) UpsertDog(
	ctx context.Context,
	value *Dog,
	constraintNames []string,
	fieldMask pggen.FieldSet,
	opts ...pggen.UpsertOpt,
) (ret int64, err error)

Upsert a Dog value. If the given value conflicts with an existing row in the database, use the provided value to update that row rather than inserting it. Only the fields specified by 'fieldMask' are actually updated. All other fields are left as-is.

type SizeCategory

type SizeCategory int
const (
	SizeCategorySmall SizeCategory = iota
	SizeCategoryLarge SizeCategory = iota
)

func SizeCategoryFromString

func SizeCategoryFromString(s string) (SizeCategory, error)

func (*SizeCategory) Scan

func (s *SizeCategory) Scan(value interface{}) error

func (SizeCategory) String

func (t SizeCategory) String() string

type TxPGClient

type TxPGClient struct {
	// contains filtered or unexported fields
}

A postgres client that operates within a transaction. Supports all the same generated methods that PGClient does.

func (*TxPGClient) BulkDeleteDog

func (tx *TxPGClient) BulkDeleteDog(
	ctx context.Context,
	ids []int64,
	opts ...pggen.DeleteOpt,
) error

func (*TxPGClient) BulkInsertDog

func (tx *TxPGClient) BulkInsertDog(
	ctx context.Context,
	values []Dog,
	opts ...pggen.InsertOpt,
) ([]int64, error)

Insert a list of Dog. Returns a list of the primary keys of the inserted rows.

func (*TxPGClient) BulkUpsertDog

func (tx *TxPGClient) BulkUpsertDog(
	ctx context.Context,
	values []Dog,
	constraintNames []string,
	fieldMask pggen.FieldSet,
	opts ...pggen.UpsertOpt,
) (ret []int64, err error)

Upsert a set of Dog values. If any of the given values conflict with existing rows in the database, use the provided values to update the rows which exist in the database rather than inserting them. Only the fields specified by 'fieldMask' are actually updated. All other fields are left as-is.

func (*TxPGClient) Commit

func (tx *TxPGClient) Commit() error

func (*TxPGClient) DeleteDog

func (tx *TxPGClient) DeleteDog(
	ctx context.Context,
	id int64,
	opts ...pggen.DeleteOpt,
) error

func (*TxPGClient) DogBulkFillIncludes

func (tx *TxPGClient) DogBulkFillIncludes(
	ctx context.Context,
	recs []*Dog,
	includes *include.Spec,
	opts ...pggen.IncludeOpt,
) error

func (*TxPGClient) DogFillIncludes

func (tx *TxPGClient) DogFillIncludes(
	ctx context.Context,
	rec *Dog,
	includes *include.Spec,
	opts ...pggen.IncludeOpt,
) error

func (*TxPGClient) GetDog

func (tx *TxPGClient) GetDog(
	ctx context.Context,
	id int64,
	opts ...pggen.GetOpt,
) (*Dog, error)

func (*TxPGClient) Handle

func (tx *TxPGClient) Handle() pggen.DBHandle

func (*TxPGClient) InsertDog

func (tx *TxPGClient) InsertDog(
	ctx context.Context,
	value *Dog,
	opts ...pggen.InsertOpt,
) (ret int64, err error)

Insert a Dog into the database. Returns the primary key of the inserted row.

func (*TxPGClient) ListDog

func (tx *TxPGClient) ListDog(
	ctx context.Context,
	ids []int64,
	opts ...pggen.ListOpt,
) (ret []Dog, err error)

func (*TxPGClient) Rollback

func (tx *TxPGClient) Rollback() error

func (*TxPGClient) UpdateDog

func (tx *TxPGClient) UpdateDog(
	ctx context.Context,
	value *Dog,
	fieldMask pggen.FieldSet,
	opts ...pggen.UpdateOpt,
) (ret int64, err error)

Update a Dog. 'value' must at the least have a primary key set. The 'fieldMask' field set indicates which fields should be updated in the database.

Returns the primary key of the updated row.

func (*TxPGClient) UpsertDog

func (tx *TxPGClient) UpsertDog(
	ctx context.Context,
	value *Dog,
	constraintNames []string,
	fieldMask pggen.FieldSet,
	opts ...pggen.UpsertOpt,
) (ret int64, err error)

Upsert a Dog value. If the given value conflicts with an existing row in the database, use the provided value to update that row rather than inserting it. Only the fields specified by 'fieldMask' are actually updated. All other fields are left as-is.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL