Documentation
¶
Index ¶
- Constants
- Variables
- type ConnPGClient
- func (conn *ConnPGClient) BulkDeleteUser(ctx context.Context, ids []int64, opts ...pggen.DeleteOpt) error
- func (conn *ConnPGClient) BulkInsertUser(ctx context.Context, values []User, opts ...pggen.InsertOpt) ([]int64, error)
- func (conn *ConnPGClient) BulkUpsertUser(ctx context.Context, values []User, constraintNames []string, ...) (ret []int64, err error)
- func (conn *ConnPGClient) Close() error
- func (conn *ConnPGClient) DeleteUser(ctx context.Context, id int64, opts ...pggen.DeleteOpt) error
- func (conn *ConnPGClient) GetUser(ctx context.Context, id int64, opts ...pggen.GetOpt) (*User, error)
- func (conn *ConnPGClient) GetUsersByNullableNickname(ctx context.Context, arg1 *string) (ret []User, err error)
- func (conn *ConnPGClient) GetUsersByNullableNicknameQuery(ctx context.Context, arg1 *string) (*sql.Rows, error)
- func (conn *ConnPGClient) Handle() pggen.DBHandle
- func (conn *ConnPGClient) InsertUser(ctx context.Context, value *User, opts ...pggen.InsertOpt) (ret int64, err error)
- func (conn *ConnPGClient) ListUser(ctx context.Context, ids []int64, opts ...pggen.ListOpt) (ret []User, err error)
- func (conn *ConnPGClient) UpdateUser(ctx context.Context, value *User, fieldMask pggen.FieldSet, ...) (ret int64, err error)
- func (conn *ConnPGClient) UpsertUser(ctx context.Context, value *User, constraintNames []string, ...) (ret int64, err error)
- func (conn *ConnPGClient) UserBulkFillIncludes(ctx context.Context, recs []*User, includes *include.Spec, ...) error
- func (conn *ConnPGClient) UserFillIncludes(ctx context.Context, rec *User, includes *include.Spec, ...) error
- type DBQueries
- type PGClient
- func (p *PGClient) BeginTx(ctx context.Context, opts *sql.TxOptions) (*TxPGClient, error)
- func (p *PGClient) BulkDeleteUser(ctx context.Context, ids []int64, opts ...pggen.DeleteOpt) error
- func (p *PGClient) BulkInsertUser(ctx context.Context, values []User, opts ...pggen.InsertOpt) ([]int64, error)
- func (p *PGClient) BulkUpsertUser(ctx context.Context, values []User, constraintNames []string, ...) (ret []int64, err error)
- func (p *PGClient) Conn(ctx context.Context) (*ConnPGClient, error)
- func (p *PGClient) DeleteUser(ctx context.Context, id int64, opts ...pggen.DeleteOpt) error
- func (p *PGClient) GetUser(ctx context.Context, id int64, opts ...pggen.GetOpt) (*User, error)
- func (p *PGClient) GetUsersByNullableNickname(ctx context.Context, arg1 *string) (ret []User, err error)
- func (p *PGClient) GetUsersByNullableNicknameQuery(ctx context.Context, arg1 *string) (*sql.Rows, error)
- func (p *PGClient) Handle() pggen.DBHandle
- func (p *PGClient) InsertUser(ctx context.Context, value *User, opts ...pggen.InsertOpt) (ret int64, err error)
- func (p *PGClient) ListUser(ctx context.Context, ids []int64, opts ...pggen.ListOpt) (ret []User, err error)
- func (p *PGClient) UpdateUser(ctx context.Context, value *User, fieldMask pggen.FieldSet, ...) (ret int64, err error)
- func (p *PGClient) UpsertUser(ctx context.Context, value *User, constraintNames []string, ...) (ret int64, err error)
- func (p *PGClient) UserBulkFillIncludes(ctx context.Context, recs []*User, includes *include.Spec, ...) error
- func (p *PGClient) UserFillIncludes(ctx context.Context, rec *User, includes *include.Spec, ...) error
- type TxPGClient
- func (tx *TxPGClient) BulkDeleteUser(ctx context.Context, ids []int64, opts ...pggen.DeleteOpt) error
- func (tx *TxPGClient) BulkInsertUser(ctx context.Context, values []User, opts ...pggen.InsertOpt) ([]int64, error)
- func (tx *TxPGClient) BulkUpsertUser(ctx context.Context, values []User, constraintNames []string, ...) (ret []int64, err error)
- func (tx *TxPGClient) Commit() error
- func (tx *TxPGClient) DeleteUser(ctx context.Context, id int64, opts ...pggen.DeleteOpt) error
- func (tx *TxPGClient) GetUser(ctx context.Context, id int64, opts ...pggen.GetOpt) (*User, error)
- func (tx *TxPGClient) GetUsersByNullableNickname(ctx context.Context, arg1 *string) (ret []User, err error)
- func (tx *TxPGClient) GetUsersByNullableNicknameQuery(ctx context.Context, arg1 *string) (*sql.Rows, error)
- func (tx *TxPGClient) Handle() pggen.DBHandle
- func (tx *TxPGClient) InsertUser(ctx context.Context, value *User, opts ...pggen.InsertOpt) (ret int64, err error)
- func (tx *TxPGClient) ListUser(ctx context.Context, ids []int64, opts ...pggen.ListOpt) (ret []User, err error)
- func (tx *TxPGClient) Rollback() error
- func (tx *TxPGClient) UpdateUser(ctx context.Context, value *User, fieldMask pggen.FieldSet, ...) (ret int64, err error)
- func (tx *TxPGClient) UpsertUser(ctx context.Context, value *User, constraintNames []string, ...) (ret int64, err error)
- func (tx *TxPGClient) UserBulkFillIncludes(ctx context.Context, recs []*User, includes *include.Spec, ...) error
- func (tx *TxPGClient) UserFillIncludes(ctx context.Context, rec *User, includes *include.Spec, ...) error
- type User
Constants ¶
const ( UserIdFieldIndex int = 0 UserEmailFieldIndex int = 1 UserNicknameFieldIndex int = 2 UserMaxFieldIndex int = (3 - 1) )
bit indicies for 'fieldMask' parameters
Variables ¶
var UserAllFields pggen.FieldSet = pggen.NewFieldSetFilled(3)
A field set saying that all fields in User should be updated. For use as a 'fieldMask' parameter
Functions ¶
This section is empty.
Types ¶
type ConnPGClient ¶
type ConnPGClient struct {
// contains filtered or unexported fields
}
func (*ConnPGClient) BulkDeleteUser ¶
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 (*ConnPGClient) GetUsersByNullableNickname ¶
func (conn *ConnPGClient) GetUsersByNullableNickname( ctx context.Context, arg1 *string, ) (ret []User, err error)
This query looks up users by their nickname, even if that nickname is NULL.
Note the funny `nickname = $1 OR (nickname IS NULL AND $1 IS NULL)` construct. This is a common pattern when querying based on possibly-null parameters. The reason for this has to do with SQL's trinary logic and null propigation. In the context of of most programming languages nulls mean something like "a reference to nothing", but in SQL it is better to think of NULL as meaning "unknown". What is `nickname = UNKNOWN`? Well, we don't know what is on the rhs, so the whole thing is `UNKNOWN`. What about `UNKNOWN OR true`? Well, all we need to know is that one side of the OR is true in order for the whole thing to be true, so the whole expression is `true`.
If we just wrote `WHERE nickname = $1` as would make sense in most programming languages, we would end up with `WHERE UNKNOWN` when `$1` is NULL, and SQL will only return queries where it knows for sure that the WHERE condition is true, so we would never be able to return any results when `$1` is NULL. If that was the case there would be no point in generating code for nullable arguments in the first place.
func (*ConnPGClient) GetUsersByNullableNicknameQuery ¶
func (conn *ConnPGClient) GetUsersByNullableNicknameQuery( ctx context.Context, arg1 *string, ) (*sql.Rows, error)
This query looks up users by their nickname, even if that nickname is NULL.
Note the funny `nickname = $1 OR (nickname IS NULL AND $1 IS NULL)` construct. This is a common pattern when querying based on possibly-null parameters. The reason for this has to do with SQL's trinary logic and null propigation. In the context of of most programming languages nulls mean something like "a reference to nothing", but in SQL it is better to think of NULL as meaning "unknown". What is `nickname = UNKNOWN`? Well, we don't know what is on the rhs, so the whole thing is `UNKNOWN`. What about `UNKNOWN OR true`? Well, all we need to know is that one side of the OR is true in order for the whole thing to be true, so the whole expression is `true`.
If we just wrote `WHERE nickname = $1` as would make sense in most programming languages, we would end up with `WHERE UNKNOWN` when `$1` is NULL, and SQL will only return queries where it knows for sure that the WHERE condition is true, so we would never be able to return any results when `$1` is NULL. If that was the case there would be no point in generating code for nullable arguments in the first place.
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) 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 // GetUsersByNullableNickname query GetUsersByNullableNickname( ctx context.Context, arg1 *string, ) ([]User, error) GetUsersByNullableNicknameQuery( ctx context.Context, arg1 string, ) (*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 ¶
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) BulkDeleteUser ¶
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) DeleteUser ¶
func (*PGClient) GetUsersByNullableNickname ¶
func (p *PGClient) GetUsersByNullableNickname( ctx context.Context, arg1 *string, ) (ret []User, err error)
This query looks up users by their nickname, even if that nickname is NULL.
Note the funny `nickname = $1 OR (nickname IS NULL AND $1 IS NULL)` construct. This is a common pattern when querying based on possibly-null parameters. The reason for this has to do with SQL's trinary logic and null propigation. In the context of of most programming languages nulls mean something like "a reference to nothing", but in SQL it is better to think of NULL as meaning "unknown". What is `nickname = UNKNOWN`? Well, we don't know what is on the rhs, so the whole thing is `UNKNOWN`. What about `UNKNOWN OR true`? Well, all we need to know is that one side of the OR is true in order for the whole thing to be true, so the whole expression is `true`.
If we just wrote `WHERE nickname = $1` as would make sense in most programming languages, we would end up with `WHERE UNKNOWN` when `$1` is NULL, and SQL will only return queries where it knows for sure that the WHERE condition is true, so we would never be able to return any results when `$1` is NULL. If that was the case there would be no point in generating code for nullable arguments in the first place.
func (*PGClient) GetUsersByNullableNicknameQuery ¶
func (p *PGClient) GetUsersByNullableNicknameQuery( ctx context.Context, arg1 *string, ) (*sql.Rows, error)
This query looks up users by their nickname, even if that nickname is NULL.
Note the funny `nickname = $1 OR (nickname IS NULL AND $1 IS NULL)` construct. This is a common pattern when querying based on possibly-null parameters. The reason for this has to do with SQL's trinary logic and null propigation. In the context of of most programming languages nulls mean something like "a reference to nothing", but in SQL it is better to think of NULL as meaning "unknown". What is `nickname = UNKNOWN`? Well, we don't know what is on the rhs, so the whole thing is `UNKNOWN`. What about `UNKNOWN OR true`? Well, all we need to know is that one side of the OR is true in order for the whole thing to be true, so the whole expression is `true`.
If we just wrote `WHERE nickname = $1` as would make sense in most programming languages, we would end up with `WHERE UNKNOWN` when `$1` is NULL, and SQL will only return queries where it knows for sure that the WHERE condition is true, so we would never be able to return any results when `$1` is NULL. If that was the case there would be no point in generating code for nullable arguments in the first place.
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) 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 ¶
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 (*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 (*TxPGClient) GetUsersByNullableNickname ¶
func (tx *TxPGClient) GetUsersByNullableNickname( ctx context.Context, arg1 *string, ) (ret []User, err error)
This query looks up users by their nickname, even if that nickname is NULL.
Note the funny `nickname = $1 OR (nickname IS NULL AND $1 IS NULL)` construct. This is a common pattern when querying based on possibly-null parameters. The reason for this has to do with SQL's trinary logic and null propigation. In the context of of most programming languages nulls mean something like "a reference to nothing", but in SQL it is better to think of NULL as meaning "unknown". What is `nickname = UNKNOWN`? Well, we don't know what is on the rhs, so the whole thing is `UNKNOWN`. What about `UNKNOWN OR true`? Well, all we need to know is that one side of the OR is true in order for the whole thing to be true, so the whole expression is `true`.
If we just wrote `WHERE nickname = $1` as would make sense in most programming languages, we would end up with `WHERE UNKNOWN` when `$1` is NULL, and SQL will only return queries where it knows for sure that the WHERE condition is true, so we would never be able to return any results when `$1` is NULL. If that was the case there would be no point in generating code for nullable arguments in the first place.
func (*TxPGClient) GetUsersByNullableNicknameQuery ¶
func (tx *TxPGClient) GetUsersByNullableNicknameQuery( ctx context.Context, arg1 *string, ) (*sql.Rows, error)
This query looks up users by their nickname, even if that nickname is NULL.
Note the funny `nickname = $1 OR (nickname IS NULL AND $1 IS NULL)` construct. This is a common pattern when querying based on possibly-null parameters. The reason for this has to do with SQL's trinary logic and null propigation. In the context of of most programming languages nulls mean something like "a reference to nothing", but in SQL it is better to think of NULL as meaning "unknown". What is `nickname = UNKNOWN`? Well, we don't know what is on the rhs, so the whole thing is `UNKNOWN`. What about `UNKNOWN OR true`? Well, all we need to know is that one side of the OR is true in order for the whole thing to be true, so the whole expression is `true`.
If we just wrote `WHERE nickname = $1` as would make sense in most programming languages, we would end up with `WHERE UNKNOWN` when `$1` is NULL, and SQL will only return queries where it knows for sure that the WHERE condition is true, so we would never be able to return any results when `$1` is NULL. If that was the case there would be no point in generating code for nullable arguments in the first place.
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) 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