Documentation
¶
Index ¶
- Constants
- type Address
- type AddressTable
- func (tbl AddressTable) BeginTx(opts *pgx.TxOptions) (AddressTable, error)
- func (tbl AddressTable) Constraints() constraint.Constraints
- func (tbl AddressTable) Count(wh where.Expression) (count int64, err error)
- func (tbl AddressTable) CountWhere(where string, args ...interface{}) (count int64, err error)
- func (tbl AddressTable) CreateIndexes(ifNotExist bool) (err error)
- func (tbl AddressTable) CreatePostcodeIdxIndex(ifNotExist bool) error
- func (tbl AddressTable) CreateTable(ifNotExists bool) (int64, error)
- func (tbl AddressTable) CreateTableWithIndexes(ifNotExist bool) (err error)
- func (tbl AddressTable) CreateTownIdxIndex(ifNotExist bool) error
- func (tbl AddressTable) Ctx() context.Context
- func (tbl AddressTable) DB() pgxapi.SqlDB
- func (tbl AddressTable) Database() pgxapi.Database
- func (tbl AddressTable) Delete(req require.Requirement, wh where.Expression) (int64, error)
- func (tbl AddressTable) DeleteAddresses(req require.Requirement, id ...int64) (int64, error)
- func (tbl AddressTable) Dialect() dialect.Dialect
- func (tbl AddressTable) DropIndexes(ifExist bool) (err error)
- func (tbl AddressTable) DropPostcodeIdxIndex(ifExists bool) error
- func (tbl AddressTable) DropTable(ifExists bool) (int64, error)
- func (tbl AddressTable) DropTownIdxIndex(ifExists bool) error
- func (tbl AddressTable) Exec(req require.Requirement, query string, args ...interface{}) (int64, error)
- func (tbl AddressTable) Execer() pgxapi.Execer
- func (tbl AddressTable) Fetch(req require.Requirement, query string, args ...interface{}) ([]*Address, error)
- func (tbl AddressTable) GetAddressById(req require.Requirement, id int64) (*Address, error)
- func (tbl AddressTable) GetAddressesById(req require.Requirement, id ...int64) (list []*Address, err error)
- func (tbl AddressTable) GetAddressesByPostcode(req require.Requirement, postcode string) ([]*Address, error)
- func (tbl AddressTable) GetAddressesByTown(req require.Requirement, town string) ([]*Address, error)
- func (tbl AddressTable) Insert(req require.Requirement, vv ...*Address) error
- func (tbl AddressTable) IsTx() bool
- func (tbl AddressTable) Logger() pgxapi.Logger
- func (tbl AddressTable) Name() pgxapi.TableName
- func (tbl AddressTable) PkColumn() string
- func (tbl AddressTable) Query(req require.Requirement, query string, args ...interface{}) ([]*Address, error)
- func (tbl AddressTable) QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)
- func (tbl AddressTable) QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)
- func (tbl AddressTable) QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)
- func (tbl AddressTable) Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*Address, error)
- func (tbl AddressTable) SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*Address, error)
- func (tbl AddressTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Address, error)
- func (tbl AddressTable) SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Address, error)
- func (tbl AddressTable) SetPkColumn(pk string) AddressTable
- func (tbl AddressTable) SliceId(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
- func (tbl AddressTable) SlicePostcode(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
- func (tbl AddressTable) SliceTown(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
- func (tbl AddressTable) Truncate(force bool) (err error)
- func (tbl AddressTable) Tx() pgxapi.SqlTx
- func (tbl AddressTable) Update(req require.Requirement, vv ...*Address) (int64, error)
- func (tbl AddressTable) UpdateFields(req require.Requirement, wh where.Expression, fields ...sql.NamedArg) (int64, error)
- func (tbl AddressTable) Upsert(v *Address, wh where.Expression) error
- func (tbl AddressTable) Using(tx pgxapi.SqlTx) AddressTable
- func (tbl AddressTable) WithConstraint(cc ...constraint.Constraint) AddressTable
- func (tbl AddressTable) WithContext(ctx context.Context) AddressTable
- func (tbl AddressTable) WithPrefix(pfx string) AddressTable
- type DbUserTable
- func (tbl DbUserTable) BeginTx(opts *pgx.TxOptions) (DbUserTable, error)
- func (tbl DbUserTable) Constraints() constraint.Constraints
- func (tbl DbUserTable) Count(wh where.Expression) (count int64, err error)
- func (tbl DbUserTable) CountWhere(where string, args ...interface{}) (count int64, err error)
- func (tbl DbUserTable) CreateEmailaddressIdxIndex(ifNotExist bool) error
- func (tbl DbUserTable) CreateIndexes(ifNotExist bool) (err error)
- func (tbl DbUserTable) CreateTable(ifNotExists bool) (int64, error)
- func (tbl DbUserTable) CreateTableWithIndexes(ifNotExist bool) (err error)
- func (tbl DbUserTable) CreateUserLoginIndex(ifNotExist bool) error
- func (tbl DbUserTable) Ctx() context.Context
- func (tbl DbUserTable) DB() pgxapi.SqlDB
- func (tbl DbUserTable) Database() pgxapi.Database
- func (tbl DbUserTable) Delete(req require.Requirement, wh where.Expression) (int64, error)
- func (tbl DbUserTable) DeleteUsers(req require.Requirement, id ...int64) (int64, error)
- func (tbl DbUserTable) Dialect() dialect.Dialect
- func (tbl DbUserTable) DropEmailaddressIdxIndex(ifExists bool) error
- func (tbl DbUserTable) DropIndexes(ifExist bool) (err error)
- func (tbl DbUserTable) DropTable(ifExists bool) (int64, error)
- func (tbl DbUserTable) DropUserLoginIndex(ifExists bool) error
- func (tbl DbUserTable) Exec(req require.Requirement, query string, args ...interface{}) (int64, error)
- func (tbl DbUserTable) Execer() pgxapi.Execer
- func (tbl DbUserTable) Fetch(req require.Requirement, query string, args ...interface{}) ([]*User, error)
- func (tbl DbUserTable) GetUserByEmailAddress(req require.Requirement, emailaddress string) (*User, error)
- func (tbl DbUserTable) GetUserByName(req require.Requirement, name string) (*User, error)
- func (tbl DbUserTable) GetUserByUid(req require.Requirement, id int64) (*User, error)
- func (tbl DbUserTable) GetUsersByUid(req require.Requirement, id ...int64) (list []*User, err error)
- func (tbl DbUserTable) Insert(req require.Requirement, vv ...*User) error
- func (tbl DbUserTable) IsTx() bool
- func (tbl DbUserTable) Logger() pgxapi.Logger
- func (tbl DbUserTable) Name() pgxapi.TableName
- func (tbl DbUserTable) PkColumn() string
- func (tbl DbUserTable) Query(req require.Requirement, query string, args ...interface{}) ([]*User, error)
- func (tbl DbUserTable) QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)
- func (tbl DbUserTable) QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)
- func (tbl DbUserTable) QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)
- func (tbl DbUserTable) Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*User, error)
- func (tbl DbUserTable) SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*User, error)
- func (tbl DbUserTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*User, error)
- func (tbl DbUserTable) SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*User, error)
- func (tbl DbUserTable) SetPkColumn(pk string) DbUserTable
- func (tbl DbUserTable) SliceAddressid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
- func (tbl DbUserTable) SliceAvatar(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
- func (tbl DbUserTable) SliceEmailaddress(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
- func (tbl DbUserTable) SliceF32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float32, error)
- func (tbl DbUserTable) SliceF64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float64, error)
- func (tbl DbUserTable) SliceI16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int16, error)
- func (tbl DbUserTable) SliceI32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int32, error)
- func (tbl DbUserTable) SliceI64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
- func (tbl DbUserTable) SliceI8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int8, error)
- func (tbl DbUserTable) SliceLastupdated(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
- func (tbl DbUserTable) SliceName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
- func (tbl DbUserTable) SliceRole(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Role, error)
- func (tbl DbUserTable) SliceU16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint16, error)
- func (tbl DbUserTable) SliceU32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint32, error)
- func (tbl DbUserTable) SliceU64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint64, error)
- func (tbl DbUserTable) SliceU8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint8, error)
- func (tbl DbUserTable) SliceUid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
- func (tbl DbUserTable) Truncate(force bool) (err error)
- func (tbl DbUserTable) Tx() pgxapi.SqlTx
- func (tbl DbUserTable) Update(req require.Requirement, vv ...*User) (int64, error)
- func (tbl DbUserTable) UpdateFields(req require.Requirement, wh where.Expression, fields ...sql.NamedArg) (int64, error)
- func (tbl DbUserTable) Upsert(v *User, wh where.Expression) error
- func (tbl DbUserTable) Using(tx pgxapi.SqlTx) DbUserTable
- func (tbl DbUserTable) WithConstraint(cc ...constraint.Constraint) DbUserTable
- func (tbl DbUserTable) WithContext(ctx context.Context) DbUserTable
- func (tbl DbUserTable) WithPrefix(pfx string) DbUserTable
- type Numbers
- type Role
- type User
- func (u *User) PostGet() error
- func (u *User) PreInsert() error
- func (u *User) PreUpdate() error
- func (v *User) SetActive(x bool) *User
- func (v *User) SetAddressId(x int64) *User
- func (v *User) SetAdmin(x bool) *User
- func (v *User) SetAvatar(x string) *User
- func (v *User) SetEmailAddress(x string) *User
- func (v *User) SetF32(x float32) *User
- func (v *User) SetF64(x float64) *User
- func (v *User) SetFave(x big.Int) *User
- func (v *User) SetI16(x int16) *User
- func (v *User) SetI32(x int32) *User
- func (v *User) SetI64(x int64) *User
- func (v *User) SetI8(x int8) *User
- func (v *User) SetLastUpdated(x int64) *User
- func (v *User) SetName(x string) *User
- func (v *User) SetRole(x Role) *User
- func (v *User) SetU16(x uint16) *User
- func (v *User) SetU32(x uint32) *User
- func (v *User) SetU64(x uint64) *User
- func (v *User) SetU8(x uint8) *User
- func (v *User) SetUid(x int64) *User
- func (v *User) Setsecret(x string) *User
- func (v *User) Settoken(x string) *User
Constants ¶
const AddressTableColumnNames = "id,lines,town,postcode"
AddressTableColumnNames is the list of columns in AddressTable.
const AddressTableDataColumnNames = "lines,town,postcode"
AddressTableDataColumnNames is the list of data columns in AddressTable.
const DbUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
DbUserTableColumnNames is the list of columns in DbUserTable.
const DbUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
DbUserTableDataColumnNames is the list of data columns in DbUserTable.
const NumAddressTableColumns = 4
NumAddressTableColumns is the total number of columns in AddressTable.
const NumAddressTableDataColumns = 3
NumAddressTableDataColumns is the number of columns in AddressTable not including the auto-increment key.
const NumDbUserTableColumns = 22
NumDbUserTableColumns is the total number of columns in DbUserTable.
const NumDbUserTableDataColumns = 21
NumDbUserTableDataColumns is the number of columns in DbUserTable not including the auto-increment key.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
Id int64 `sql:"pk: true, auto: true"`
Lines []string `sql:"encode: json"`
Town *string `sql:"size: 80, index: townIdx"`
Postcode string `sql:"size: 20, index: postcodeIdx"`
}
func ScanAddresses ¶ added in v0.50.0
func ScanAddresses(query string, rows pgxapi.SqlRows, firstOnly bool) (vv []*Address, n int64, err error)
ScanAddresses reads rows from the database and returns a slice of corresponding values. It also returns a number indicating how many rows were read; this will be larger than the length of the slice if reading stopped after the first row.
type AddressTable ¶
type AddressTable struct {
// contains filtered or unexported fields
}
AddressTable holds a given table name with the database reference, providing access methods below. The Prefix field is often blank but can be used to hold a table name prefix (e.g. ending in '_'). Or it can specify the name of the schema, in which case it should have a trailing '.'.
func CopyTableAsAddressTable ¶
func CopyTableAsAddressTable(origin pgxapi.Table) AddressTable
CopyTableAsAddressTable copies a table instance, retaining the name etc but providing methods appropriate for 'Address'. It doesn't copy the constraints of the original table.
It serves to provide methods appropriate for 'Address'. This is most useful when this is used to represent a join result. In such cases, there won't be any need for DDL methods, nor Exec, Insert, Update or Delete.
func NewAddressTable ¶
func NewAddressTable(name string, d pgxapi.Database) AddressTable
NewAddressTable returns a new table instance. If a blank table name is supplied, the default name "addresses" will be used instead. The request context is initialised with the background.
func (AddressTable) BeginTx ¶
func (tbl AddressTable) BeginTx(opts *pgx.TxOptions) (AddressTable, error)
BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.
If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.
The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.
Panics if the Execer is not TxStarter.
func (AddressTable) Constraints ¶
func (tbl AddressTable) Constraints() constraint.Constraints
Constraints returns the table's constraints.
func (AddressTable) Count ¶
func (tbl AddressTable) Count(wh where.Expression) (count int64, err error)
Count counts the Addresses in the table that match a 'where' clause. Use a nil value for the 'wh' argument if it is not needed.
func (AddressTable) CountWhere ¶
func (tbl AddressTable) CountWhere(where string, args ...interface{}) (count int64, err error)
CountWhere counts Addresses in the table that match a 'where' clause. Use a blank string for the 'where' argument if it is not needed.
The args are for any placeholder parameters in the query.
func (AddressTable) CreateIndexes ¶
func (tbl AddressTable) CreateIndexes(ifNotExist bool) (err error)
CreateIndexes executes queries that create the indexes needed by the Address table.
func (AddressTable) CreatePostcodeIdxIndex ¶
func (tbl AddressTable) CreatePostcodeIdxIndex(ifNotExist bool) error
CreatePostcodeIdxIndex creates the postcodeIdx index.
func (AddressTable) CreateTable ¶
func (tbl AddressTable) CreateTable(ifNotExists bool) (int64, error)
CreateTable creates the table.
func (AddressTable) CreateTableWithIndexes ¶
func (tbl AddressTable) CreateTableWithIndexes(ifNotExist bool) (err error)
CreateTableWithIndexes invokes CreateTable then CreateIndexes.
func (AddressTable) CreateTownIdxIndex ¶
func (tbl AddressTable) CreateTownIdxIndex(ifNotExist bool) error
CreateTownIdxIndex creates the townIdx index.
func (AddressTable) Ctx ¶
func (tbl AddressTable) Ctx() context.Context
Ctx gets the current request context.
func (AddressTable) DB ¶
func (tbl AddressTable) DB() pgxapi.SqlDB
DB gets the wrapped database handle, provided this is not within a transaction. Panics if it is in the wrong state - use IsTx() if necessary.
func (AddressTable) Database ¶
func (tbl AddressTable) Database() pgxapi.Database
Database gets the shared database information.
func (AddressTable) Delete ¶
func (tbl AddressTable) Delete(req require.Requirement, wh where.Expression) (int64, error)
Delete deletes one or more rows from the table, given a 'where' clause. Use a nil value for the 'wh' argument if it is not needed (very risky!).
func (AddressTable) DeleteAddresses ¶
func (tbl AddressTable) DeleteAddresses(req require.Requirement, id ...int64) (int64, error)
DeleteAddresses deletes rows from the table, given some primary keys. The list of ids can be arbitrarily long.
func (AddressTable) Dialect ¶
func (tbl AddressTable) Dialect() dialect.Dialect
Dialect gets the database dialect.
func (AddressTable) DropIndexes ¶
func (tbl AddressTable) DropIndexes(ifExist bool) (err error)
DropIndexes executes queries that drop the indexes on by the Address table.
func (AddressTable) DropPostcodeIdxIndex ¶
func (tbl AddressTable) DropPostcodeIdxIndex(ifExists bool) error
DropPostcodeIdxIndex drops the postcodeIdx index.
func (AddressTable) DropTable ¶
func (tbl AddressTable) DropTable(ifExists bool) (int64, error)
DropTable drops the table, destroying all its data.
func (AddressTable) DropTownIdxIndex ¶
func (tbl AddressTable) DropTownIdxIndex(ifExists bool) error
DropTownIdxIndex drops the townIdx index.
func (AddressTable) Exec ¶
func (tbl AddressTable) Exec(req require.Requirement, query string, args ...interface{}) (int64, error)
Exec executes a query without returning any rows. It returns the number of rows affected (if the database driver supports this).
The args are for any placeholder parameters in the query.
func (AddressTable) Execer ¶
func (tbl AddressTable) Execer() pgxapi.Execer
Execer gets the wrapped database or transaction handle.
func (AddressTable) Fetch ¶
func (tbl AddressTable) Fetch(req require.Requirement, query string, args ...interface{}) ([]*Address, error)
Fetch fetches a list of Address based on a supplied query. This is mostly used for join queries that map its result columns to the fields of Address. Other queries might be better handled by GetXxx or Select methods.
func (AddressTable) GetAddressById ¶
func (tbl AddressTable) GetAddressById(req require.Requirement, id int64) (*Address, error)
GetAddressById gets the record with a given primary key value. If not found, *Address will be nil.
func (AddressTable) GetAddressesById ¶
func (tbl AddressTable) GetAddressesById(req require.Requirement, id ...int64) (list []*Address, err error)
GetAddressesById gets records from the table according to a list of primary keys. Although the list of ids can be arbitrarily long, there are practical limits; note that Oracle DB has a limit of 1000.
It places a requirement, which may be nil, on the size of the expected results: in particular, require.All controls whether an error is generated not all the ids produce a result.
func (AddressTable) GetAddressesByPostcode ¶
func (tbl AddressTable) GetAddressesByPostcode(req require.Requirement, postcode string) ([]*Address, error)
GetAddressesByPostcode gets the records with a given postcode value. If not found, the resulting slice will be empty (nil).
func (AddressTable) GetAddressesByTown ¶
func (tbl AddressTable) GetAddressesByTown(req require.Requirement, town string) ([]*Address, error)
GetAddressesByTown gets the records with a given town value. If not found, the resulting slice will be empty (nil).
func (AddressTable) Insert ¶
func (tbl AddressTable) Insert(req require.Requirement, vv ...*Address) error
Insert adds new records for the Addresses. The Addresses have their primary key fields set to the new record identifiers. The Address.PreInsert() method will be called, if it exists.
func (AddressTable) IsTx ¶
func (tbl AddressTable) IsTx() bool
IsTx tests whether this is within a transaction.
func (AddressTable) Logger ¶
func (tbl AddressTable) Logger() pgxapi.Logger
Logger gets the trace logger.
func (AddressTable) Name ¶
func (tbl AddressTable) Name() pgxapi.TableName
Name gets the table name.
func (AddressTable) PkColumn ¶
func (tbl AddressTable) PkColumn() string
PkColumn gets the column name used as a primary key.
func (AddressTable) Query ¶
func (tbl AddressTable) Query(req require.Requirement, query string, args ...interface{}) ([]*Address, error)
Query is the low-level request method for this table. The SQL query must return all the columns necessary for Address values. Placeholders should be vanilla '?' marks, which will be replaced if necessary according to the chosen dialect.
The query is logged using whatever logger is configured. If an error arises, this too is logged.
If you need a context other than the background, use WithContext before calling Query.
The args are for any placeholder parameters in the query.
The support API provides a core 'support.Query' function, on which this method depends. If appropriate, use that function directly; wrap the result in *pgxapi.Rows if you need to access its data as a map.
func (AddressTable) QueryOneNullFloat64 ¶
func (tbl AddressTable) QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)
QueryOneNullFloat64 is a low-level access method for one float64. This can be used for 'AVG(...)' queries and such like. If the query selected many rows, only the first is returned; the rest are discarded. If not found, the result will be invalid.
Note that this applies ReplaceTableName to the query string.
The args are for any placeholder parameters in the query.
func (AddressTable) QueryOneNullInt64 ¶
func (tbl AddressTable) QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)
QueryOneNullInt64 is a low-level access method for one int64. This can be used for 'COUNT(1)' queries and such like. If the query selected many rows, only the first is returned; the rest are discarded. If not found, the result will be invalid.
Note that this applies ReplaceTableName to the query string.
The args are for any placeholder parameters in the query.
func (AddressTable) QueryOneNullString ¶
func (tbl AddressTable) QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)
QueryOneNullString is a low-level access method for one string. This can be used for function queries and such like. If the query selected many rows, only the first is returned; the rest are discarded. If not found, the result will be invalid.
Note that this applies ReplaceTableName to the query string.
The args are for any placeholder parameters in the query.
func (AddressTable) Select ¶
func (tbl AddressTable) Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*Address, error)
Select allows Addresses to be obtained from the table that match a 'where' clause. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
It places a requirement, which may be nil, on the size of the expected results: for example require.AtLeastOne controls whether an error is generated when no result is found.
func (AddressTable) SelectOne ¶
func (tbl AddressTable) SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*Address, error)
SelectOne allows a single Address to be obtained from the database. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed. If not found, *Example will be nil.
It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.
func (AddressTable) SelectOneWhere ¶
func (tbl AddressTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Address, error)
SelectOneWhere allows a single Example to be obtained from the table that match a 'where' clause and some limit. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed. If not found, *Example will be nil.
It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.
The args are for any placeholder parameters in the query.
func (AddressTable) SelectWhere ¶
func (tbl AddressTable) SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Address, error)
SelectWhere allows Addresses to be obtained from the table that match a 'where' clause. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed.
It places a requirement, which may be nil, on the size of the expected results: for example require.AtLeastOne controls whether an error is generated when no result is found.
The args are for any placeholder parameters in the query.
func (AddressTable) SetPkColumn ¶
func (tbl AddressTable) SetPkColumn(pk string) AddressTable
SetPkColumn sets the name of the primary key column. It defaults to "id". The result is a modified copy of the table; the original is unchanged.
func (AddressTable) SliceId ¶
func (tbl AddressTable) SliceId(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
SliceId gets the id column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (AddressTable) SlicePostcode ¶
func (tbl AddressTable) SlicePostcode(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
SlicePostcode gets the postcode column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (AddressTable) SliceTown ¶
func (tbl AddressTable) SliceTown(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
SliceTown gets the town column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (AddressTable) Truncate ¶
func (tbl AddressTable) Truncate(force bool) (err error)
Truncate drops every record from the table, if possible. It might fail if constraints exist that prevent some or all rows from being deleted; use the force option to override this.
When 'force' is set true, be aware of the following consequences. When using Mysql, foreign keys in other tables can be left dangling. When using Postgres, a cascade happens, so all 'adjacent' tables (i.e. linked by foreign keys) are also truncated.
func (AddressTable) Tx ¶
func (tbl AddressTable) Tx() pgxapi.SqlTx
Tx gets the wrapped transaction handle, provided this is within a transaction. Panics if it is in the wrong state - use IsTx() if necessary.
func (AddressTable) Update ¶
func (tbl AddressTable) Update(req require.Requirement, vv ...*Address) (int64, error)
Update updates records, matching them by primary key. It returns the number of rows affected. The Address.PreUpdate(Execer) method will be called, if it exists.
func (AddressTable) UpdateFields ¶
func (tbl AddressTable) UpdateFields(req require.Requirement, wh where.Expression, fields ...sql.NamedArg) (int64, error)
UpdateFields updates one or more columns, given a 'where' clause. Use a nil value for the 'wh' argument if it is not needed (very risky!).
func (AddressTable) Upsert ¶
func (tbl AddressTable) Upsert(v *Address, wh where.Expression) error
Upsert inserts or updates a record, matching it using the expression supplied. This expression is used to search for an existing record based on some specified key column(s). It must match either zero or one existing record. If it matches none, a new record is inserted; otherwise the matching record is updated. An error results if these conditions are not met.
func (AddressTable) Using ¶
func (tbl AddressTable) Using(tx pgxapi.SqlTx) AddressTable
Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.
func (AddressTable) WithConstraint ¶
func (tbl AddressTable) WithConstraint(cc ...constraint.Constraint) AddressTable
WithConstraint returns a modified Table with added data consistency constraints.
func (AddressTable) WithContext ¶
func (tbl AddressTable) WithContext(ctx context.Context) AddressTable
WithContext sets the context for subsequent queries via this table. The result is a modified copy of the table; the original is unchanged.
The shared context in the *Database is not altered by this method. So it is possible to use different contexts for different (groups of) queries.
func (AddressTable) WithPrefix ¶
func (tbl AddressTable) WithPrefix(pfx string) AddressTable
WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.
type DbUserTable ¶
type DbUserTable struct {
// contains filtered or unexported fields
}
DbUserTable holds a given table name with the database reference, providing access methods below. The Prefix field is often blank but can be used to hold a table name prefix (e.g. ending in '_'). Or it can specify the name of the schema, in which case it should have a trailing '.'.
func CopyTableAsDbUserTable ¶
func CopyTableAsDbUserTable(origin pgxapi.Table) DbUserTable
CopyTableAsDbUserTable copies a table instance, retaining the name etc but providing methods appropriate for 'User'. It doesn't copy the constraints of the original table.
It serves to provide methods appropriate for 'User'. This is most useful when this is used to represent a join result. In such cases, there won't be any need for DDL methods, nor Exec, Insert, Update or Delete.
func NewDbUserTable ¶
func NewDbUserTable(name string, d pgxapi.Database) DbUserTable
NewDbUserTable returns a new table instance. If a blank table name is supplied, the default name "the_users" will be used instead. The request context is initialised with the background.
func (DbUserTable) BeginTx ¶
func (tbl DbUserTable) BeginTx(opts *pgx.TxOptions) (DbUserTable, error)
BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.
If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.
The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.
Panics if the Execer is not TxStarter.
func (DbUserTable) Constraints ¶
func (tbl DbUserTable) Constraints() constraint.Constraints
Constraints returns the table's constraints.
func (DbUserTable) Count ¶
func (tbl DbUserTable) Count(wh where.Expression) (count int64, err error)
Count counts the Users in the table that match a 'where' clause. Use a nil value for the 'wh' argument if it is not needed.
func (DbUserTable) CountWhere ¶
func (tbl DbUserTable) CountWhere(where string, args ...interface{}) (count int64, err error)
CountWhere counts Users in the table that match a 'where' clause. Use a blank string for the 'where' argument if it is not needed.
The args are for any placeholder parameters in the query.
func (DbUserTable) CreateEmailaddressIdxIndex ¶
func (tbl DbUserTable) CreateEmailaddressIdxIndex(ifNotExist bool) error
CreateEmailaddressIdxIndex creates the emailaddress_idx index.
func (DbUserTable) CreateIndexes ¶
func (tbl DbUserTable) CreateIndexes(ifNotExist bool) (err error)
CreateIndexes executes queries that create the indexes needed by the User table.
func (DbUserTable) CreateTable ¶
func (tbl DbUserTable) CreateTable(ifNotExists bool) (int64, error)
CreateTable creates the table.
func (DbUserTable) CreateTableWithIndexes ¶
func (tbl DbUserTable) CreateTableWithIndexes(ifNotExist bool) (err error)
CreateTableWithIndexes invokes CreateTable then CreateIndexes.
func (DbUserTable) CreateUserLoginIndex ¶
func (tbl DbUserTable) CreateUserLoginIndex(ifNotExist bool) error
CreateUserLoginIndex creates the user_login index.
func (DbUserTable) Ctx ¶
func (tbl DbUserTable) Ctx() context.Context
Ctx gets the current request context.
func (DbUserTable) DB ¶
func (tbl DbUserTable) DB() pgxapi.SqlDB
DB gets the wrapped database handle, provided this is not within a transaction. Panics if it is in the wrong state - use IsTx() if necessary.
func (DbUserTable) Database ¶
func (tbl DbUserTable) Database() pgxapi.Database
Database gets the shared database information.
func (DbUserTable) Delete ¶
func (tbl DbUserTable) Delete(req require.Requirement, wh where.Expression) (int64, error)
Delete deletes one or more rows from the table, given a 'where' clause. Use a nil value for the 'wh' argument if it is not needed (very risky!).
func (DbUserTable) DeleteUsers ¶
func (tbl DbUserTable) DeleteUsers(req require.Requirement, id ...int64) (int64, error)
DeleteUsers deletes rows from the table, given some primary keys. The list of ids can be arbitrarily long.
func (DbUserTable) Dialect ¶
func (tbl DbUserTable) Dialect() dialect.Dialect
Dialect gets the database dialect.
func (DbUserTable) DropEmailaddressIdxIndex ¶
func (tbl DbUserTable) DropEmailaddressIdxIndex(ifExists bool) error
DropEmailaddressIdxIndex drops the emailaddress_idx index.
func (DbUserTable) DropIndexes ¶
func (tbl DbUserTable) DropIndexes(ifExist bool) (err error)
DropIndexes executes queries that drop the indexes on by the User table.
func (DbUserTable) DropTable ¶
func (tbl DbUserTable) DropTable(ifExists bool) (int64, error)
DropTable drops the table, destroying all its data.
func (DbUserTable) DropUserLoginIndex ¶
func (tbl DbUserTable) DropUserLoginIndex(ifExists bool) error
DropUserLoginIndex drops the user_login index.
func (DbUserTable) Exec ¶
func (tbl DbUserTable) Exec(req require.Requirement, query string, args ...interface{}) (int64, error)
Exec executes a query without returning any rows. It returns the number of rows affected (if the database driver supports this).
The args are for any placeholder parameters in the query.
func (DbUserTable) Execer ¶
func (tbl DbUserTable) Execer() pgxapi.Execer
Execer gets the wrapped database or transaction handle.
func (DbUserTable) Fetch ¶
func (tbl DbUserTable) Fetch(req require.Requirement, query string, args ...interface{}) ([]*User, error)
Fetch fetches a list of User based on a supplied query. This is mostly used for join queries that map its result columns to the fields of User. Other queries might be better handled by GetXxx or Select methods.
func (DbUserTable) GetUserByEmailAddress ¶
func (tbl DbUserTable) GetUserByEmailAddress(req require.Requirement, emailaddress string) (*User, error)
GetUserByEmailAddress gets the record with a given emailaddress value. If not found, *User will be nil.
func (DbUserTable) GetUserByName ¶
func (tbl DbUserTable) GetUserByName(req require.Requirement, name string) (*User, error)
GetUserByName gets the record with a given name value. If not found, *User will be nil.
func (DbUserTable) GetUserByUid ¶
func (tbl DbUserTable) GetUserByUid(req require.Requirement, id int64) (*User, error)
GetUserByUid gets the record with a given primary key value. If not found, *User will be nil.
func (DbUserTable) GetUsersByUid ¶
func (tbl DbUserTable) GetUsersByUid(req require.Requirement, id ...int64) (list []*User, err error)
GetUsersByUid gets records from the table according to a list of primary keys. Although the list of ids can be arbitrarily long, there are practical limits; note that Oracle DB has a limit of 1000.
It places a requirement, which may be nil, on the size of the expected results: in particular, require.All controls whether an error is generated not all the ids produce a result.
func (DbUserTable) Insert ¶
func (tbl DbUserTable) Insert(req require.Requirement, vv ...*User) error
Insert adds new records for the Users. The Users have their primary key fields set to the new record identifiers. The User.PreInsert() method will be called, if it exists.
func (DbUserTable) IsTx ¶
func (tbl DbUserTable) IsTx() bool
IsTx tests whether this is within a transaction.
func (DbUserTable) Logger ¶
func (tbl DbUserTable) Logger() pgxapi.Logger
Logger gets the trace logger.
func (DbUserTable) PkColumn ¶
func (tbl DbUserTable) PkColumn() string
PkColumn gets the column name used as a primary key.
func (DbUserTable) Query ¶
func (tbl DbUserTable) Query(req require.Requirement, query string, args ...interface{}) ([]*User, error)
Query is the low-level request method for this table. The SQL query must return all the columns necessary for User values. Placeholders should be vanilla '?' marks, which will be replaced if necessary according to the chosen dialect.
The query is logged using whatever logger is configured. If an error arises, this too is logged.
If you need a context other than the background, use WithContext before calling Query.
The args are for any placeholder parameters in the query.
The support API provides a core 'support.Query' function, on which this method depends. If appropriate, use that function directly; wrap the result in *pgxapi.Rows if you need to access its data as a map.
func (DbUserTable) QueryOneNullFloat64 ¶
func (tbl DbUserTable) QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)
QueryOneNullFloat64 is a low-level access method for one float64. This can be used for 'AVG(...)' queries and such like. If the query selected many rows, only the first is returned; the rest are discarded. If not found, the result will be invalid.
Note that this applies ReplaceTableName to the query string.
The args are for any placeholder parameters in the query.
func (DbUserTable) QueryOneNullInt64 ¶
func (tbl DbUserTable) QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)
QueryOneNullInt64 is a low-level access method for one int64. This can be used for 'COUNT(1)' queries and such like. If the query selected many rows, only the first is returned; the rest are discarded. If not found, the result will be invalid.
Note that this applies ReplaceTableName to the query string.
The args are for any placeholder parameters in the query.
func (DbUserTable) QueryOneNullString ¶
func (tbl DbUserTable) QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)
QueryOneNullString is a low-level access method for one string. This can be used for function queries and such like. If the query selected many rows, only the first is returned; the rest are discarded. If not found, the result will be invalid.
Note that this applies ReplaceTableName to the query string.
The args are for any placeholder parameters in the query.
func (DbUserTable) Select ¶
func (tbl DbUserTable) Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*User, error)
Select allows Users to be obtained from the table that match a 'where' clause. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
It places a requirement, which may be nil, on the size of the expected results: for example require.AtLeastOne controls whether an error is generated when no result is found.
func (DbUserTable) SelectOne ¶
func (tbl DbUserTable) SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*User, error)
SelectOne allows a single User to be obtained from the database. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed. If not found, *Example will be nil.
It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.
func (DbUserTable) SelectOneWhere ¶
func (tbl DbUserTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*User, error)
SelectOneWhere allows a single Example to be obtained from the table that match a 'where' clause and some limit. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed. If not found, *Example will be nil.
It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.
The args are for any placeholder parameters in the query.
func (DbUserTable) SelectWhere ¶
func (tbl DbUserTable) SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*User, error)
SelectWhere allows Users to be obtained from the table that match a 'where' clause. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed.
It places a requirement, which may be nil, on the size of the expected results: for example require.AtLeastOne controls whether an error is generated when no result is found.
The args are for any placeholder parameters in the query.
func (DbUserTable) SetPkColumn ¶
func (tbl DbUserTable) SetPkColumn(pk string) DbUserTable
SetPkColumn sets the name of the primary key column. It defaults to "uid". The result is a modified copy of the table; the original is unchanged.
func (DbUserTable) SliceAddressid ¶
func (tbl DbUserTable) SliceAddressid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
SliceAddressid gets the addressid column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceAvatar ¶
func (tbl DbUserTable) SliceAvatar(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
SliceAvatar gets the avatar column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceEmailaddress ¶
func (tbl DbUserTable) SliceEmailaddress(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
SliceEmailaddress gets the emailaddress column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceF32 ¶
func (tbl DbUserTable) SliceF32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float32, error)
SliceF32 gets the f32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceF64 ¶
func (tbl DbUserTable) SliceF64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float64, error)
SliceF64 gets the f64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceI16 ¶
func (tbl DbUserTable) SliceI16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int16, error)
SliceI16 gets the i16 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceI32 ¶
func (tbl DbUserTable) SliceI32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int32, error)
SliceI32 gets the i32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceI64 ¶
func (tbl DbUserTable) SliceI64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
SliceI64 gets the i64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceI8 ¶
func (tbl DbUserTable) SliceI8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int8, error)
SliceI8 gets the i8 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceLastupdated ¶
func (tbl DbUserTable) SliceLastupdated(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
SliceLastupdated gets the lastupdated column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceName ¶
func (tbl DbUserTable) SliceName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)
SliceName gets the name column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceRole ¶
func (tbl DbUserTable) SliceRole(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Role, error)
SliceRole gets the role column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceU16 ¶
func (tbl DbUserTable) SliceU16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint16, error)
SliceU16 gets the u16 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceU32 ¶
func (tbl DbUserTable) SliceU32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint32, error)
SliceU32 gets the u32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceU64 ¶
func (tbl DbUserTable) SliceU64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint64, error)
SliceU64 gets the u64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceU8 ¶
func (tbl DbUserTable) SliceU8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint8, error)
SliceU8 gets the u8 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) SliceUid ¶
func (tbl DbUserTable) SliceUid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)
SliceUid gets the uid column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.
func (DbUserTable) Truncate ¶
func (tbl DbUserTable) Truncate(force bool) (err error)
Truncate drops every record from the table, if possible. It might fail if constraints exist that prevent some or all rows from being deleted; use the force option to override this.
When 'force' is set true, be aware of the following consequences. When using Mysql, foreign keys in other tables can be left dangling. When using Postgres, a cascade happens, so all 'adjacent' tables (i.e. linked by foreign keys) are also truncated.
func (DbUserTable) Tx ¶
func (tbl DbUserTable) Tx() pgxapi.SqlTx
Tx gets the wrapped transaction handle, provided this is within a transaction. Panics if it is in the wrong state - use IsTx() if necessary.
func (DbUserTable) Update ¶
func (tbl DbUserTable) Update(req require.Requirement, vv ...*User) (int64, error)
Update updates records, matching them by primary key. It returns the number of rows affected. The User.PreUpdate(Execer) method will be called, if it exists.
func (DbUserTable) UpdateFields ¶
func (tbl DbUserTable) UpdateFields(req require.Requirement, wh where.Expression, fields ...sql.NamedArg) (int64, error)
UpdateFields updates one or more columns, given a 'where' clause. Use a nil value for the 'wh' argument if it is not needed (very risky!).
func (DbUserTable) Upsert ¶
func (tbl DbUserTable) Upsert(v *User, wh where.Expression) error
Upsert inserts or updates a record, matching it using the expression supplied. This expression is used to search for an existing record based on some specified key column(s). It must match either zero or one existing record. If it matches none, a new record is inserted; otherwise the matching record is updated. An error results if these conditions are not met.
func (DbUserTable) Using ¶
func (tbl DbUserTable) Using(tx pgxapi.SqlTx) DbUserTable
Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.
func (DbUserTable) WithConstraint ¶
func (tbl DbUserTable) WithConstraint(cc ...constraint.Constraint) DbUserTable
WithConstraint returns a modified Table with added data consistency constraints.
func (DbUserTable) WithContext ¶
func (tbl DbUserTable) WithContext(ctx context.Context) DbUserTable
WithContext sets the context for subsequent queries via this table. The result is a modified copy of the table; the original is unchanged.
The shared context in the *Database is not altered by this method. So it is possible to use different contexts for different (groups of) queries.
func (DbUserTable) WithPrefix ¶
func (tbl DbUserTable) WithPrefix(pfx string) DbUserTable
WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.
type Numbers ¶
type Numbers struct {
I8 int8 `sql:"default: -8"`
U8 uint8 `sql:"default: 8"`
I16 int16 `sql:"default: -16"`
U16 uint16 `sql:"default: 16"`
I32 int32 `sql:"default: -32"`
U32 uint32 `sql:"default: 32"`
I64 int64 `sql:"default: -64"`
U64 uint64 `sql:"default: 64"`
F32 float32 `sql:"default: 3.2"`
F64 float64 `sql:"default: 6.4"`
}
type User ¶
type User struct {
Uid int64 `sql:"pk: true, auto: true"`
Name string `sql:"unique: user_login"`
EmailAddress string `sql:"nk: true"`
AddressId *int64 `sql:"fk: addresses.id, onupdate: restrict, ondelete: restrict"`
Avatar *string
Role *Role `sql:"type: text, size: 20"`
Active bool
Admin bool
Fave *big.Int `sql:"encode: json"`
LastUpdated int64
// something just to aid test coverage
Numbers Numbers
// contains filtered or unexported fields
}
func ScanDbUsers ¶ added in v0.50.0
func ScanDbUsers(query string, rows pgxapi.SqlRows, firstOnly bool) (vv []*User, n int64, err error)
ScanDbUsers reads rows from the database and returns a slice of corresponding values. It also returns a number indicating how many rows were read; this will be larger than the length of the slice if reading stopped after the first row.
func (*User) PreInsert ¶
These hooks are just used here for testing, but you could put whatever you like in them.
func (*User) SetAddressId ¶
SetAddressId sets the AddressId field and returns the modified User.
func (*User) SetEmailAddress ¶
SetEmailAddress sets the EmailAddress field and returns the modified User.
func (*User) SetLastUpdated ¶
SetLastUpdated sets the LastUpdated field and returns the modified User.