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 (
	UserIdFieldIndex       int = 0
	UserEmailFieldIndex    int = 1
	UserNicknameFieldIndex int = 2
	UserMaxFieldIndex      int = (3 - 1)
)

bit indicies for 'fieldMask' parameters

Variables

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

View Source
var UserAllIncludes *include.Spec = include.Must(include.Parse(
	`users`,
))

Functions

This section is empty.

Types

type ConnPGClient

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

func (*ConnPGClient) BulkDeleteUser

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

func (*ConnPGClient) BulkInsertUser

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

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

func (*ConnPGClient) BulkUpsertUser

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

Upsert a set of User 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) DeleteUser

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

func (*ConnPGClient) GetUser

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

func (*ConnPGClient) GetUserNicknameAndEmail

func (conn *ConnPGClient) GetUserNicknameAndEmail(
	ctx context.Context,
	arg1 int64,
) (ret []GetUserNicknameAndEmailRow, err error)

This comment will end up on the methods that are generated based on the query.

func (*ConnPGClient) GetUserNicknameAndEmailQuery

func (conn *ConnPGClient) GetUserNicknameAndEmailQuery(
	ctx context.Context,
	arg1 int64,
) (*sql.Rows, error)

This comment will end up on the methods that are generated based on the query.

func (*ConnPGClient) Handle

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

func (*ConnPGClient) InsertUser

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

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

func (*ConnPGClient) ListUser

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

func (*ConnPGClient) MyGetUser

func (conn *ConnPGClient) MyGetUser(
	ctx context.Context,
	arg1 int64,
) (ret []User, err error)

This query returns a model struct. We let pggen know that via the return_type configuration option.

func (*ConnPGClient) MyGetUserQuery

func (conn *ConnPGClient) MyGetUserQuery(
	ctx context.Context,
	arg1 int64,
) (*sql.Rows, error)

This query returns a model struct. We let pggen know that via the return_type configuration option.

func (*ConnPGClient) UpdateUser

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

Update a User. '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) UpsertUser

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

Upsert a User 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) UserBulkFillIncludes

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

func (*ConnPGClient) UserFillIncludes

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

type DBQueries

type DBQueries interface {

	// User methods
	GetUser(ctx context.Context, id int64, opts ...pggen.GetOpt) (*User, error)
	ListUser(ctx context.Context, ids []int64, opts ...pggen.ListOpt) ([]User, error)
	InsertUser(ctx context.Context, value *User, opts ...pggen.InsertOpt) (int64, error)
	BulkInsertUser(ctx context.Context, values []User, opts ...pggen.InsertOpt) ([]int64, error)
	UpdateUser(ctx context.Context, value *User, fieldMask pggen.FieldSet, opts ...pggen.UpdateOpt) (ret int64, err error)
	UpsertUser(ctx context.Context, value *User, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) (int64, error)
	BulkUpsertUser(ctx context.Context, values []User, constraintNames []string, fieldMask pggen.FieldSet, opts ...pggen.UpsertOpt) ([]int64, error)
	DeleteUser(ctx context.Context, id int64, opts ...pggen.DeleteOpt) error
	BulkDeleteUser(ctx context.Context, ids []int64, opts ...pggen.DeleteOpt) error
	UserFillIncludes(ctx context.Context, rec *User, includes *include.Spec, opts ...pggen.IncludeOpt) error
	UserBulkFillIncludes(ctx context.Context, recs []*User, includes *include.Spec, opts ...pggen.IncludeOpt) error

	// GetUserNicknameAndEmail query
	GetUserNicknameAndEmail(
		ctx context.Context,
		arg1 int64,
	) ([]GetUserNicknameAndEmailRow, error)
	GetUserNicknameAndEmailQuery(
		ctx context.Context,
		arg1 int64,
	) (*sql.Rows, error)

	// MyGetUser query
	MyGetUser(
		ctx context.Context,
		arg1 int64,
	) ([]User, error)
	MyGetUserQuery(
		ctx context.Context,
		arg1 int64,
	) (*sql.Rows, error)
}

type GetUserNicknameAndEmailRow

type GetUserNicknameAndEmailRow struct {
	Nickname string  ``
	Email    *string ``
}

func (*GetUserNicknameAndEmailRow) Scan

func (r *GetUserNicknameAndEmailRow) 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) BulkDeleteUser

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

func (*PGClient) BulkInsertUser

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

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

func (*PGClient) BulkUpsertUser

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

Upsert a set of User 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) DeleteUser

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

func (*PGClient) GetUser

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

func (*PGClient) GetUserNicknameAndEmail

func (p *PGClient) GetUserNicknameAndEmail(
	ctx context.Context,
	arg1 int64,
) (ret []GetUserNicknameAndEmailRow, err error)

This comment will end up on the methods that are generated based on the query.

func (*PGClient) GetUserNicknameAndEmailQuery

func (p *PGClient) GetUserNicknameAndEmailQuery(
	ctx context.Context,
	arg1 int64,
) (*sql.Rows, error)

This comment will end up on the methods that are generated based on the query.

func (*PGClient) Handle

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

func (*PGClient) InsertUser

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

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

func (*PGClient) ListUser

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

func (*PGClient) MyGetUser

func (p *PGClient) MyGetUser(
	ctx context.Context,
	arg1 int64,
) (ret []User, err error)

This query returns a model struct. We let pggen know that via the return_type configuration option.

func (*PGClient) MyGetUserQuery

func (p *PGClient) MyGetUserQuery(
	ctx context.Context,
	arg1 int64,
) (*sql.Rows, error)

This query returns a model struct. We let pggen know that via the return_type configuration option.

func (*PGClient) UpdateUser

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

Update a User. '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) UpsertUser

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

Upsert a User 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) UserBulkFillIncludes

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

func (*PGClient) UserFillIncludes

func (p *PGClient) UserFillIncludes(
	ctx context.Context,
	rec *User,
	includes *include.Spec,
	opts ...pggen.IncludeOpt,
) 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) BulkDeleteUser

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

func (*TxPGClient) BulkInsertUser

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

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

func (*TxPGClient) BulkUpsertUser

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

Upsert a set of User 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) DeleteUser

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

func (*TxPGClient) GetUser

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

func (*TxPGClient) GetUserNicknameAndEmail

func (tx *TxPGClient) GetUserNicknameAndEmail(
	ctx context.Context,
	arg1 int64,
) (ret []GetUserNicknameAndEmailRow, err error)

This comment will end up on the methods that are generated based on the query.

func (*TxPGClient) GetUserNicknameAndEmailQuery

func (tx *TxPGClient) GetUserNicknameAndEmailQuery(
	ctx context.Context,
	arg1 int64,
) (*sql.Rows, error)

This comment will end up on the methods that are generated based on the query.

func (*TxPGClient) Handle

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

func (*TxPGClient) InsertUser

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

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

func (*TxPGClient) ListUser

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

func (*TxPGClient) MyGetUser

func (tx *TxPGClient) MyGetUser(
	ctx context.Context,
	arg1 int64,
) (ret []User, err error)

This query returns a model struct. We let pggen know that via the return_type configuration option.

func (*TxPGClient) MyGetUserQuery

func (tx *TxPGClient) MyGetUserQuery(
	ctx context.Context,
	arg1 int64,
) (*sql.Rows, error)

This query returns a model struct. We let pggen know that via the return_type configuration option.

func (*TxPGClient) Rollback

func (tx *TxPGClient) Rollback() error

func (*TxPGClient) UpdateUser

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

Update a User. '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) UpsertUser

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

Upsert a User 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) UserBulkFillIncludes

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

func (*TxPGClient) UserFillIncludes

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

type User

type User struct {
	Id       int64  `gorm:"column:id;is_primary"`
	Email    string `gorm:"column:email"`
	Nickname string `gorm:"column:nickname"`
}

func (*User) Scan

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

Jump to

Keyboard shortcuts

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