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 (
	FooIdFieldIndex    int = 0
	FooValueFieldIndex int = 1
	FooMaxFieldIndex   int = (2 - 1)
)

bit indicies for 'fieldMask' parameters

Variables

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

View Source
var FooAllIncludes *include.Spec = include.Must(include.Parse(
	`foos`,
))

Functions

This section is empty.

Types

type ConnPGClient

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

func (*ConnPGClient) BulkDeleteFoo

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

func (*ConnPGClient) BulkInsertFoo

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

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

func (*ConnPGClient) BulkUpsertFoo

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

Upsert a set of Foo 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) DeleteFoo

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

func (*ConnPGClient) FooBulkFillIncludes

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

func (*ConnPGClient) FooFillIncludes

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

func (*ConnPGClient) GetFoo

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

func (*ConnPGClient) Handle

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

func (*ConnPGClient) InsertFoo

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

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

func (*ConnPGClient) ListFoo

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

func (*ConnPGClient) MyGetFooValue

func (conn *ConnPGClient) MyGetFooValue(
	ctx context.Context,
	arg1 int64,
) (ret *string, err error)

func (*ConnPGClient) UpdateFoo

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

Update a Foo. '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) UpsertFoo

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

Upsert a Foo 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 {

	// Foo methods
	GetFoo(ctx context.Context, id int64, opts ...pggen.GetOpt) (*Foo, error)
	ListFoo(ctx context.Context, ids []int64, opts ...pggen.ListOpt) ([]Foo, error)
	InsertFoo(ctx context.Context, value *Foo, opts ...pggen.InsertOpt) (int64, error)
	BulkInsertFoo(ctx context.Context, values []Foo, opts ...pggen.InsertOpt) ([]int64, error)
	UpdateFoo(ctx context.Context, value *Foo, fieldMask pggen.FieldSet, opts ...pggen.UpdateOpt) (ret int64, err error)
	UpsertFoo(ctx context.Context, value *Foo, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) (int64, error)
	BulkUpsertFoo(ctx context.Context, values []Foo, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) ([]int64, error)
	DeleteFoo(ctx context.Context, id int64, opts ...pggen.DeleteOpt) error
	BulkDeleteFoo(ctx context.Context, ids []int64, opts ...pggen.DeleteOpt) error
	FooFillIncludes(ctx context.Context, rec *Foo, includes *include.Spec, opts ...pggen.IncludeOpt) error
	FooBulkFillIncludes(ctx context.Context, recs []*Foo, includes *include.Spec, opts ...pggen.IncludeOpt) error

	// MyGetFooValue query
	MyGetFooValue(
		ctx context.Context,
		arg1 int64,
	) (*string, error)
}

type Foo

type Foo struct {
	Id    int64   `gorm:"column:id;is_primary"`
	Value *string `gorm:"column:value"`
}

func (*Foo) Scan

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

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) BulkDeleteFoo

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

func (*PGClient) BulkInsertFoo

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

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

func (*PGClient) BulkUpsertFoo

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

Upsert a set of Foo 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) DeleteFoo

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

func (*PGClient) FooBulkFillIncludes

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

func (*PGClient) FooFillIncludes

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

func (*PGClient) GetFoo

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

func (*PGClient) Handle

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

func (*PGClient) InsertFoo

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

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

func (*PGClient) ListFoo

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

func (*PGClient) MyGetFooValue

func (p *PGClient) MyGetFooValue(
	ctx context.Context,
	arg1 int64,
) (ret *string, err error)

func (*PGClient) UpdateFoo

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

Update a Foo. '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) UpsertFoo

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

Upsert a Foo 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 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) BulkDeleteFoo

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

func (*TxPGClient) BulkInsertFoo

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

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

func (*TxPGClient) BulkUpsertFoo

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

Upsert a set of Foo 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) DeleteFoo

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

func (*TxPGClient) FooBulkFillIncludes

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

func (*TxPGClient) FooFillIncludes

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

func (*TxPGClient) GetFoo

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

func (*TxPGClient) Handle

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

func (*TxPGClient) InsertFoo

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

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

func (*TxPGClient) ListFoo

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

func (*TxPGClient) MyGetFooValue

func (tx *TxPGClient) MyGetFooValue(
	ctx context.Context,
	arg1 int64,
) (ret *string, err error)

func (*TxPGClient) Rollback

func (tx *TxPGClient) Rollback() error

func (*TxPGClient) UpdateFoo

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

Update a Foo. '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) UpsertFoo

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

Upsert a Foo 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