models

package
v0.3.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	GrandparentIdFieldIndex                 int = 0
	GrandparentNameFieldIndex               int = 1
	GrandparentFavoriteGrandkidIdFieldIndex int = 2
	GrandparentMaxFieldIndex                int = (3 - 1)
)

bit indicies for 'fieldMask' parameters

View Source
const (
	ParentIdFieldIndex            int = 0
	ParentGrandparentIdFieldIndex int = 1
	ParentNameFieldIndex          int = 2
	ParentMaxFieldIndex           int = (3 - 1)
)

bit indicies for 'fieldMask' parameters

View Source
const (
	ChildIdFieldIndex       int = 0
	ChildParentIdFieldIndex int = 1
	ChildNameFieldIndex     int = 2
	ChildMaxFieldIndex      int = (3 - 1)
)

bit indicies for 'fieldMask' parameters

Variables

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

View Source
var ChildAllIncludes *include.Spec = include.Must(include.Parse(
	`children.{darling_grandparents->grandparents.{favorite_grandkid->children,parents.{children,grandparents}},parents}`,
))
View Source
var GrandparentAllFields pggen.FieldSet = pggen.NewFieldSetFilled(3)

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

View Source
var GrandparentAllIncludes *include.Spec = include.Must(include.Parse(
	`grandparents.{favorite_grandkid->children.{darling_grandparents->grandparents,parents.{children,grandparents}},parents}`,
))
View Source
var ParentAllFields pggen.FieldSet = pggen.NewFieldSetFilled(3)

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

View Source
var ParentAllIncludes *include.Spec = include.Must(include.Parse(
	`parents.{children.{darling_grandparents->grandparents.{favorite_grandkid->children,parents},parents},grandparents}`,
))

Functions

This section is empty.

Types

type Child

type Child struct {
	Id                  int64          `gorm:"column:id;is_primary"`
	ParentId            int64          `gorm:"column:parent_id"`
	Name                string         `gorm:"column:name"`
	DarlingGrandparents []*Grandparent `gorm:"foreignKey:FavoriteGrandkidId"`
	Parent              *Parent
}

func (*Child) Scan

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

type ConnPGClient

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

func (*ConnPGClient) BulkDeleteChild

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

func (*ConnPGClient) BulkDeleteGrandparent

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

func (*ConnPGClient) BulkDeleteParent

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

func (*ConnPGClient) BulkInsertChild

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

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

func (*ConnPGClient) BulkInsertGrandparent

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

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

func (*ConnPGClient) BulkInsertParent

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

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

func (*ConnPGClient) BulkUpsertChild

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

Upsert a set of Child 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) BulkUpsertGrandparent

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

Upsert a set of Grandparent 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) BulkUpsertParent

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

Upsert a set of Parent 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) ChildBulkFillIncludes

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

func (*ConnPGClient) ChildFillIncludes

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

func (*ConnPGClient) Close

func (conn *ConnPGClient) Close() error

func (*ConnPGClient) DeleteChild

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

func (*ConnPGClient) DeleteGrandparent

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

func (*ConnPGClient) DeleteParent

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

func (*ConnPGClient) GetChild

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

func (*ConnPGClient) GetGrandparent

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

func (*ConnPGClient) GetParent

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

func (*ConnPGClient) GrandparentBulkFillIncludes

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

func (*ConnPGClient) GrandparentFillIncludes

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

func (*ConnPGClient) Handle

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

func (*ConnPGClient) InsertChild

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

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

func (*ConnPGClient) InsertGrandparent

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

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

func (*ConnPGClient) InsertParent

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

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

func (*ConnPGClient) ListChild

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

func (*ConnPGClient) ListGrandparent

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

func (*ConnPGClient) ListParent

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

func (*ConnPGClient) ParentBulkFillIncludes

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

func (*ConnPGClient) ParentFillIncludes

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

func (*ConnPGClient) UpdateChild

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

Update a Child. '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) UpdateGrandparent

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

Update a Grandparent. '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) UpdateParent

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

Update a Parent. '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) UpsertChild

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

Upsert a Child 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.

func (*ConnPGClient) UpsertGrandparent

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

Upsert a Grandparent 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.

func (*ConnPGClient) UpsertParent

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

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

	// Grandparent methods
	GetGrandparent(ctx context.Context, id int64, opts ...pggen.GetOpt) (*Grandparent, error)
	ListGrandparent(ctx context.Context, ids []int64, opts ...pggen.ListOpt) ([]Grandparent, error)
	InsertGrandparent(ctx context.Context, value *Grandparent, opts ...pggen.InsertOpt) (int64, error)
	BulkInsertGrandparent(ctx context.Context, values []Grandparent, opts ...pggen.InsertOpt) ([]int64, error)
	UpdateGrandparent(ctx context.Context, value *Grandparent, fieldMask pggen.FieldSet, opts ...pggen.UpdateOpt) (ret int64, err error)
	UpsertGrandparent(ctx context.Context, value *Grandparent, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) (int64, error)
	BulkUpsertGrandparent(ctx context.Context, values []Grandparent, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) ([]int64, error)
	DeleteGrandparent(ctx context.Context, id int64, opts ...pggen.DeleteOpt) error
	BulkDeleteGrandparent(ctx context.Context, ids []int64, opts ...pggen.DeleteOpt) error
	GrandparentFillIncludes(ctx context.Context, rec *Grandparent, includes *include.Spec, opts ...pggen.IncludeOpt) error
	GrandparentBulkFillIncludes(ctx context.Context, recs []*Grandparent, includes *include.Spec, opts ...pggen.IncludeOpt) error

	// Parent methods
	GetParent(ctx context.Context, id int64, opts ...pggen.GetOpt) (*Parent, error)
	ListParent(ctx context.Context, ids []int64, opts ...pggen.ListOpt) ([]Parent, error)
	InsertParent(ctx context.Context, value *Parent, opts ...pggen.InsertOpt) (int64, error)
	BulkInsertParent(ctx context.Context, values []Parent, opts ...pggen.InsertOpt) ([]int64, error)
	UpdateParent(ctx context.Context, value *Parent, fieldMask pggen.FieldSet, opts ...pggen.UpdateOpt) (ret int64, err error)
	UpsertParent(ctx context.Context, value *Parent, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) (int64, error)
	BulkUpsertParent(ctx context.Context, values []Parent, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) ([]int64, error)
	DeleteParent(ctx context.Context, id int64, opts ...pggen.DeleteOpt) error
	BulkDeleteParent(ctx context.Context, ids []int64, opts ...pggen.DeleteOpt) error
	ParentFillIncludes(ctx context.Context, rec *Parent, includes *include.Spec, opts ...pggen.IncludeOpt) error
	ParentBulkFillIncludes(ctx context.Context, recs []*Parent, includes *include.Spec, opts ...pggen.IncludeOpt) error

	// Child methods
	GetChild(ctx context.Context, id int64, opts ...pggen.GetOpt) (*Child, error)
	ListChild(ctx context.Context, ids []int64, opts ...pggen.ListOpt) ([]Child, error)
	InsertChild(ctx context.Context, value *Child, opts ...pggen.InsertOpt) (int64, error)
	BulkInsertChild(ctx context.Context, values []Child, opts ...pggen.InsertOpt) ([]int64, error)
	UpdateChild(ctx context.Context, value *Child, fieldMask pggen.FieldSet, opts ...pggen.UpdateOpt) (ret int64, err error)
	UpsertChild(ctx context.Context, value *Child, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) (int64, error)
	BulkUpsertChild(ctx context.Context, values []Child, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) ([]int64, error)
	DeleteChild(ctx context.Context, id int64, opts ...pggen.DeleteOpt) error
	BulkDeleteChild(ctx context.Context, ids []int64, opts ...pggen.DeleteOpt) error
	ChildFillIncludes(ctx context.Context, rec *Child, includes *include.Spec, opts ...pggen.IncludeOpt) error
	ChildBulkFillIncludes(ctx context.Context, recs []*Child, includes *include.Spec, opts ...pggen.IncludeOpt) error
}

type Grandparent

type Grandparent struct {
	Id                 int64     `gorm:"column:id;is_primary"`
	Name               string    `gorm:"column:name"`
	FavoriteGrandkidId *int64    `gorm:"column:favorite_grandkid_id"`
	Parents            []*Parent `gorm:"foreignKey:GrandparentId"`
	FavoriteGrandkid   *Child
}

func (*Grandparent) Scan

func (r *Grandparent) 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) BulkDeleteChild

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

func (*PGClient) BulkDeleteGrandparent

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

func (*PGClient) BulkDeleteParent

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

func (*PGClient) BulkInsertChild

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

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

func (*PGClient) BulkInsertGrandparent

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

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

func (*PGClient) BulkInsertParent

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

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

func (*PGClient) BulkUpsertChild

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

Upsert a set of Child 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) BulkUpsertGrandparent

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

Upsert a set of Grandparent 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) BulkUpsertParent

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

Upsert a set of Parent 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) ChildBulkFillIncludes

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

func (*PGClient) ChildFillIncludes

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

func (*PGClient) Conn

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

func (*PGClient) DeleteChild

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

func (*PGClient) DeleteGrandparent

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

func (*PGClient) DeleteParent

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

func (*PGClient) GetChild

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

func (*PGClient) GetGrandparent

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

func (*PGClient) GetParent

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

func (*PGClient) GrandparentBulkFillIncludes

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

func (*PGClient) GrandparentFillIncludes

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

func (*PGClient) Handle

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

func (*PGClient) InsertChild

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

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

func (*PGClient) InsertGrandparent

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

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

func (*PGClient) InsertParent

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

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

func (*PGClient) ListChild

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

func (*PGClient) ListGrandparent

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

func (*PGClient) ListParent

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

func (*PGClient) ParentBulkFillIncludes

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

func (*PGClient) ParentFillIncludes

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

func (*PGClient) UpdateChild

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

Update a Child. '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) UpdateGrandparent

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

Update a Grandparent. '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) UpdateParent

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

Update a Parent. '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) UpsertChild

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

Upsert a Child 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.

func (*PGClient) UpsertGrandparent

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

Upsert a Grandparent 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.

func (*PGClient) UpsertParent

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

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

type Parent struct {
	Id            int64    `gorm:"column:id;is_primary"`
	GrandparentId int64    `gorm:"column:grandparent_id"`
	Name          string   `gorm:"column:name"`
	Children      []*Child `gorm:"foreignKey:ParentId"`
	Grandparent   *Grandparent
}

func (*Parent) Scan

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

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

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

func (*TxPGClient) BulkDeleteGrandparent

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

func (*TxPGClient) BulkDeleteParent

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

func (*TxPGClient) BulkInsertChild

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

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

func (*TxPGClient) BulkInsertGrandparent

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

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

func (*TxPGClient) BulkInsertParent

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

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

func (*TxPGClient) BulkUpsertChild

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

Upsert a set of Child 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) BulkUpsertGrandparent

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

Upsert a set of Grandparent 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) BulkUpsertParent

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

Upsert a set of Parent 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) ChildBulkFillIncludes

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

func (*TxPGClient) ChildFillIncludes

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

func (*TxPGClient) Commit

func (tx *TxPGClient) Commit() error

func (*TxPGClient) DeleteChild

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

func (*TxPGClient) DeleteGrandparent

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

func (*TxPGClient) DeleteParent

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

func (*TxPGClient) GetChild

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

func (*TxPGClient) GetGrandparent

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

func (*TxPGClient) GetParent

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

func (*TxPGClient) GrandparentBulkFillIncludes

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

func (*TxPGClient) GrandparentFillIncludes

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

func (*TxPGClient) Handle

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

func (*TxPGClient) InsertChild

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

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

func (*TxPGClient) InsertGrandparent

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

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

func (*TxPGClient) InsertParent

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

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

func (*TxPGClient) ListChild

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

func (*TxPGClient) ListGrandparent

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

func (*TxPGClient) ListParent

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

func (*TxPGClient) ParentBulkFillIncludes

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

func (*TxPGClient) ParentFillIncludes

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

func (*TxPGClient) Rollback

func (tx *TxPGClient) Rollback() error

func (*TxPGClient) UpdateChild

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

Update a Child. '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) UpdateGrandparent

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

Update a Grandparent. '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) UpdateParent

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

Update a Parent. '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) UpsertChild

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

Upsert a Child 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.

func (*TxPGClient) UpsertGrandparent

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

Upsert a Grandparent 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.

func (*TxPGClient) UpsertParent

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

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