demo

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2019 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const AUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

AUserTableColumnNames is the list of columns in AUserTable.

View Source
const AUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

AUserTableDataColumnNames is the list of data columns in AUserTable.

View Source
const AddressTableColumnNames = "id,lines,town,postcode"

AddressTableColumnNames is the list of columns in AddressTable.

View Source
const AddressTableDataColumnNames = "lines,town,postcode"

AddressTableDataColumnNames is the list of data columns in AddressTable.

View Source
const AssociationTableColumnNames = "id,name,quality,ref1,ref2,category"

AssociationTableColumnNames is the list of columns in AssociationTable.

View Source
const AssociationTableDataColumnNames = "name,quality,ref1,ref2,category"

AssociationTableDataColumnNames is the list of data columns in AssociationTable.

View Source
const CUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

CUserTableColumnNames is the list of columns in CUserTable.

View Source
const CUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

CUserTableDataColumnNames is the list of data columns in CUserTable.

View Source
const DUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

DUserTableColumnNames is the list of columns in DUserTable.

View Source
const DUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

DUserTableDataColumnNames is the list of data columns in DUserTable.

View Source
const DatesTableColumnNames = "id,integer,string"

DatesTableColumnNames is the list of columns in DatesTable.

View Source
const DatesTableDataColumnNames = "integer,string"

DatesTableDataColumnNames is the list of data columns in DatesTable.

View Source
const DbCompoundTableColumnNames = "alpha,beta,category"

DbCompoundTableColumnNames is the list of columns in DbCompoundTable.

View Source
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.

View Source
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.

View Source
const EUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

EUserTableColumnNames is the list of columns in EUserTable.

View Source
const EUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

EUserTableDataColumnNames is the list of data columns in EUserTable.

View Source
const HookTableColumnNames = "" /* 242-byte string literal not displayed */

HookTableColumnNames is the list of columns in HookTable.

View Source
const HookTableDataColumnNames = "" /* 239-byte string literal not displayed */

HookTableDataColumnNames is the list of data columns in HookTable.

View Source
const IUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

IUserTableColumnNames is the list of columns in IUserTable.

View Source
const IUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

IUserTableDataColumnNames is the list of data columns in IUserTable.

View Source
const IssueTableColumnNames = "id,number,date,title,bigbody,assignee,state,labels"

IssueTableColumnNames is the list of columns in IssueTable.

View Source
const IssueTableDataColumnNames = "number,date,title,bigbody,assignee,state,labels"

IssueTableDataColumnNames is the list of data columns in IssueTable.

View Source
const LUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

LUserTableColumnNames is the list of columns in LUserTable.

View Source
const LUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

LUserTableDataColumnNames is the list of data columns in LUserTable.

View Source
const NumAUserTableColumns = 22

NumAUserTableColumns is the total number of columns in AUserTable.

View Source
const NumAUserTableDataColumns = 21

NumAUserTableDataColumns is the number of columns in AUserTable not including the auto-increment key.

View Source
const NumAddressTableColumns = 4

NumAddressTableColumns is the total number of columns in AddressTable.

View Source
const NumAddressTableDataColumns = 3

NumAddressTableDataColumns is the number of columns in AddressTable not including the auto-increment key.

View Source
const NumAssociationTableColumns = 6

NumAssociationTableColumns is the total number of columns in AssociationTable.

View Source
const NumAssociationTableDataColumns = 5

NumAssociationTableDataColumns is the number of columns in AssociationTable not including the auto-increment key.

View Source
const NumCUserTableColumns = 22

NumCUserTableColumns is the total number of columns in CUserTable.

View Source
const NumCUserTableDataColumns = 21

NumCUserTableDataColumns is the number of columns in CUserTable not including the auto-increment key.

View Source
const NumDUserTableColumns = 22

NumDUserTableColumns is the total number of columns in DUserTable.

View Source
const NumDUserTableDataColumns = 21

NumDUserTableDataColumns is the number of columns in DUserTable not including the auto-increment key.

View Source
const NumDatesTableColumns = 3

NumDatesTableColumns is the total number of columns in DatesTable.

View Source
const NumDatesTableDataColumns = 2

NumDatesTableDataColumns is the number of columns in DatesTable not including the auto-increment key.

View Source
const NumDbCompoundTableColumns = 3

NumDbCompoundTableColumns is the total number of columns in DbCompoundTable.

View Source
const NumDbCompoundTableDataColumns = 3

NumDbCompoundTableDataColumns is the number of columns in DbCompoundTable not including the auto-increment key.

View Source
const NumDbUserTableColumns = 22

NumDbUserTableColumns is the total number of columns in DbUserTable.

View Source
const NumDbUserTableDataColumns = 21

NumDbUserTableDataColumns is the number of columns in DbUserTable not including the auto-increment key.

View Source
const NumEUserTableColumns = 22

NumEUserTableColumns is the total number of columns in EUserTable.

View Source
const NumEUserTableDataColumns = 21

NumEUserTableDataColumns is the number of columns in EUserTable not including the auto-increment key.

View Source
const NumHookTableColumns = 17

NumHookTableColumns is the total number of columns in HookTable.

View Source
const NumHookTableDataColumns = 16

NumHookTableDataColumns is the number of columns in HookTable not including the auto-increment key.

View Source
const NumIUserTableColumns = 22

NumIUserTableColumns is the total number of columns in IUserTable.

View Source
const NumIUserTableDataColumns = 21

NumIUserTableDataColumns is the number of columns in IUserTable not including the auto-increment key.

View Source
const NumIssueTableColumns = 8

NumIssueTableColumns is the total number of columns in IssueTable.

View Source
const NumIssueTableDataColumns = 7

NumIssueTableDataColumns is the number of columns in IssueTable not including the auto-increment key.

View Source
const NumLUserTableColumns = 22

NumLUserTableColumns is the total number of columns in LUserTable.

View Source
const NumLUserTableDataColumns = 21

NumLUserTableDataColumns is the number of columns in LUserTable not including the auto-increment key.

View Source
const NumPUserTableColumns = 22

NumPUserTableColumns is the total number of columns in PUserTable.

View Source
const NumPUserTableDataColumns = 21

NumPUserTableDataColumns is the number of columns in PUserTable not including the auto-increment key.

View Source
const NumQUserTableColumns = 22

NumQUserTableColumns is the total number of columns in QUserTable.

View Source
const NumQUserTableDataColumns = 21

NumQUserTableDataColumns is the number of columns in QUserTable not including the auto-increment key.

View Source
const NumSUserTableColumns = 22

NumSUserTableColumns is the total number of columns in SUserTable.

View Source
const NumSUserTableDataColumns = 21

NumSUserTableDataColumns is the number of columns in SUserTable not including the auto-increment key.

View Source
const NumUUserTableColumns = 22

NumUUserTableColumns is the total number of columns in UUserTable.

View Source
const NumUUserTableDataColumns = 21

NumUUserTableDataColumns is the number of columns in UUserTable not including the auto-increment key.

View Source
const NumUserAddressJoinColumns = 12

NumUserAddressJoinColumns is the total number of columns in UserAddressJoin.

View Source
const NumUserAddressJoinDataColumns = 11

NumUserAddressJoinDataColumns is the number of columns in UserAddressJoin not including the auto-increment key.

View Source
const NumXUserTableColumns = 22

NumXUserTableColumns is the total number of columns in XUserTable.

View Source
const NumXUserTableDataColumns = 21

NumXUserTableDataColumns is the number of columns in XUserTable not including the auto-increment key.

View Source
const PUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

PUserTableColumnNames is the list of columns in PUserTable.

View Source
const PUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

PUserTableDataColumnNames is the list of data columns in PUserTable.

View Source
const QUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

QUserTableColumnNames is the list of columns in QUserTable.

View Source
const QUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

QUserTableDataColumnNames is the list of data columns in QUserTable.

View Source
const SUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

SUserTableColumnNames is the list of columns in SUserTable.

View Source
const SUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

SUserTableDataColumnNames is the list of data columns in SUserTable.

View Source
const UUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

UUserTableColumnNames is the list of columns in UUserTable.

View Source
const UUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

UUserTableDataColumnNames is the list of data columns in UUserTable.

View Source
const UserAddressJoinColumnNames = "uid,name,emailaddress,lines,town,postcode,avatar,role,active,admin,fave,lastupdated"

UserAddressJoinColumnNames is the list of columns in UserAddressJoin.

View Source
const UserAddressJoinDataColumnNames = "name,emailaddress,lines,town,postcode,avatar,role,active,admin,fave,lastupdated"

UserAddressJoinDataColumnNames is the list of data columns in UserAddressJoin.

View Source
const XUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

XUserTableColumnNames is the list of columns in XUserTable.

View Source
const XUserTableDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

XUserTableDataColumnNames is the list of data columns in XUserTable.

Variables

This section is empty.

Functions

This section is empty.

Types

type AUserTable added in v0.8.0

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

AUserTable 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 CopyTableAsAUserTable added in v0.8.0

func CopyTableAsAUserTable(origin sqlapi.Table) AUserTable

CopyTableAsAUserTable 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 NewAUserTable added in v0.8.0

func NewAUserTable(name string, d sqlapi.Database) AUserTable

NewAUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (AUserTable) Constraints added in v0.14.0

func (tbl AUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (AUserTable) Count added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) CountWhere added in v0.9.0

func (tbl AUserTable) 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 (AUserTable) CreateEmailaddressIdxIndex added in v0.16.0

func (tbl AUserTable) CreateEmailaddressIdxIndex(ifNotExist bool) error

CreateEmailaddressIdxIndex creates the emailaddress_idx index.

func (AUserTable) CreateIndexes added in v0.8.0

func (tbl AUserTable) CreateIndexes(ifNotExist bool) (err error)

CreateIndexes executes queries that create the indexes needed by the User table.

func (AUserTable) CreateTable added in v0.8.0

func (tbl AUserTable) CreateTable(ifNotExists bool) (int64, error)

CreateTable creates the table.

func (AUserTable) CreateTableWithIndexes added in v0.8.0

func (tbl AUserTable) CreateTableWithIndexes(ifNotExist bool) (err error)

CreateTableWithIndexes invokes CreateTable then CreateIndexes.

func (AUserTable) CreateUserLoginIndex added in v0.8.0

func (tbl AUserTable) CreateUserLoginIndex(ifNotExist bool) error

CreateUserLoginIndex creates the user_login index.

func (AUserTable) Ctx added in v0.8.0

func (tbl AUserTable) Ctx() context.Context

Ctx gets the current request context.

func (AUserTable) DB added in v0.8.0

func (tbl AUserTable) DB() sqlapi.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 (AUserTable) Database added in v0.12.0

func (tbl AUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (AUserTable) Delete added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) DeleteUsers added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) Dialect added in v0.8.0

func (tbl AUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (AUserTable) DropEmailaddressIdxIndex added in v0.16.0

func (tbl AUserTable) DropEmailaddressIdxIndex(ifExists bool) error

DropEmailaddressIdxIndex drops the emailaddress_idx index.

func (AUserTable) DropIndexes added in v0.8.0

func (tbl AUserTable) DropIndexes(ifExist bool) (err error)

DropIndexes executes queries that drop the indexes on by the User table.

func (AUserTable) DropTable added in v0.8.0

func (tbl AUserTable) DropTable(ifExists bool) (int64, error)

DropTable drops the table, destroying all its data.

func (AUserTable) DropUserLoginIndex added in v0.8.0

func (tbl AUserTable) DropUserLoginIndex(ifExists bool) error

DropUserLoginIndex drops the user_login index.

func (AUserTable) Exec added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) Execer added in v0.12.0

func (tbl AUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (AUserTable) Fetch added in v0.17.0

func (tbl AUserTable) 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 (AUserTable) GetUserByEmailAddress added in v0.16.0

func (tbl AUserTable) 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 (AUserTable) GetUserByName added in v0.16.0

func (tbl AUserTable) 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 (AUserTable) GetUserByUid added in v0.16.0

func (tbl AUserTable) 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 (AUserTable) GetUsersByUid added in v0.16.0

func (tbl AUserTable) 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 (AUserTable) Insert added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) IsTx added in v0.8.0

func (tbl AUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (AUserTable) Logger added in v0.8.0

func (tbl AUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (AUserTable) Name added in v0.8.0

func (tbl AUserTable) Name() sqlapi.TableName

Name gets the table name.

func (AUserTable) PkColumn added in v0.25.0

func (tbl AUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (AUserTable) Query added in v0.8.0

func (tbl AUserTable) 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 *sqlapi.Rows if you need to access its data as a map.

func (AUserTable) QueryOneNullFloat64 added in v0.9.0

func (tbl AUserTable) 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 (AUserTable) QueryOneNullInt64 added in v0.9.0

func (tbl AUserTable) 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 (AUserTable) QueryOneNullString added in v0.9.0

func (tbl AUserTable) 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 (AUserTable) Select added in v0.8.0

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 (AUserTable) SelectOne added in v0.8.0

func (tbl AUserTable) SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*User, error)

SelectOne allows a single User to be obtained from the table that matches 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. 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 (AUserTable) SelectOneWhere added in v0.9.0

func (tbl AUserTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*User, error)

SelectOneWhere allows a single User to be obtained from the table that matches 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 (AUserTable) SelectWhere added in v0.9.0

func (tbl AUserTable) 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 (AUserTable) SliceAddressid added in v0.12.0

func (tbl AUserTable) 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 (AUserTable) SliceAvatar added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) SliceEmailaddress added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) SliceF32 added in v0.19.0

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 (AUserTable) SliceF64 added in v0.19.0

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 (AUserTable) SliceI16 added in v0.19.0

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 (AUserTable) SliceI32 added in v0.19.0

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 (AUserTable) SliceI64 added in v0.19.0

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 (AUserTable) SliceI8 added in v0.19.0

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 (AUserTable) SliceLastupdated added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) SliceName added in v0.16.0

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 (AUserTable) SliceRole added in v0.10.0

func (tbl AUserTable) 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 (AUserTable) SliceU16 added in v0.19.0

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 (AUserTable) SliceU32 added in v0.19.0

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 (AUserTable) SliceU64 added in v0.19.0

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 (AUserTable) SliceU8 added in v0.19.0

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 (AUserTable) SliceUid added in v0.8.0

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 (AUserTable) Transact added in v0.51.0

func (tbl AUserTable) Transact(txOptions *sql.TxOptions, fn func(AUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (AUserTable) Truncate added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) Tx added in v0.8.0

func (tbl AUserTable) Tx() sqlapi.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 (AUserTable) Update added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) UpdateFields added in v0.8.0

func (tbl AUserTable) 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 (AUserTable) Upsert added in v0.49.0

func (tbl AUserTable) 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 (AUserTable) Using added in v0.9.0

func (tbl AUserTable) Using(tx sqlapi.SqlTx) AUserTabler

Using returns a modified AUserTabler 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 (AUserTable) WithConstraint added in v0.12.0

func (tbl AUserTable) WithConstraint(cc ...constraint.Constraint) AUserTabler

WithConstraint returns a modified AUserTabler with added data consistency constraints.

func (AUserTable) WithContext added in v0.8.0

func (tbl AUserTable) WithContext(ctx context.Context) AUserTabler

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 (AUserTable) WithPrefix added in v0.8.0

func (tbl AUserTable) WithPrefix(pfx string) AUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type AUserTabler added in v0.53.0

type AUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified AUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) AUserTabler

	// WithPrefix returns a modified AUserTabler with a given table name prefix.
	WithPrefix(pfx string) AUserTabler

	// WithContext returns a modified AUserTabler with a given context.
	WithContext(ctx context.Context) AUserTabler

	// Using returns a modified AUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) AUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(AUserTabler) error) error

	// CreateTable creates the table.
	CreateTable(ifNotExists bool) (int64, error)

	// DropTable drops the table, destroying all its data.
	DropTable(ifExists bool) (int64, error)

	// CreateTableWithIndexes invokes CreateTable then CreateIndexes.
	CreateTableWithIndexes(ifNotExist bool) (err error)

	// CreateIndexes executes queries that create the indexes needed by the User table.
	CreateIndexes(ifNotExist bool) (err error)

	// CreateEmailaddressIdxIndex creates the emailaddress_idx index.
	CreateEmailaddressIdxIndex(ifNotExist bool) error

	// DropEmailaddressIdxIndex drops the emailaddress_idx index.
	DropEmailaddressIdxIndex(ifExists bool) error

	// CreateUserLoginIndex creates the user_login index.
	CreateUserLoginIndex(ifNotExist bool) error

	// DropUserLoginIndex drops the user_login index.
	DropUserLoginIndex(ifExists bool) error

	// Truncate drops every record from the table, if possible.
	Truncate(force bool) (err error)

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for User values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*User, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

	// GetUsersByUid gets records from the table according to a list of primary keys.
	GetUsersByUid(req require.Requirement, id ...int64) (list []*User, err error)

	// GetUserByUid gets the record with a given primary key value.
	GetUserByUid(req require.Requirement, id int64) (*User, error)

	// GetUserByEmailAddress gets the record with a given emailaddress value.
	GetUserByEmailAddress(req require.Requirement, emailaddress string) (*User, error)

	// GetUserByName gets the record with a given name value.
	GetUserByName(req require.Requirement, name string) (*User, error)

	// SelectOneWhere allows a single User to be obtained from the table that matches a 'where' clause.
	SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*User, error)

	// SelectOne allows a single User to be obtained from the table that matches a 'where' clause.
	SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*User, error)

	// SelectWhere allows Users to be obtained from the table that match a 'where' clause.
	SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*User, error)

	// Select allows Users to be obtained from the table that match a 'where' clause.
	Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*User, error)

	// CountWhere counts Users in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Users in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)

	// SliceUid gets the uid column for all rows that match the 'where' condition.
	SliceUid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceName gets the name column for all rows that match the 'where' condition.
	SliceName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceEmailaddress gets the emailaddress column for all rows that match the 'where' condition.
	SliceEmailaddress(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceAddressid gets the addressid column for all rows that match the 'where' condition.
	SliceAddressid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceAvatar gets the avatar column for all rows that match the 'where' condition.
	SliceAvatar(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceLastupdated gets the lastupdated column for all rows that match the 'where' condition.
	SliceLastupdated(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceI8 gets the i8 column for all rows that match the 'where' condition.
	SliceI8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int8, error)

	// SliceU8 gets the u8 column for all rows that match the 'where' condition.
	SliceU8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint8, error)

	// SliceI16 gets the i16 column for all rows that match the 'where' condition.
	SliceI16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int16, error)

	// SliceU16 gets the u16 column for all rows that match the 'where' condition.
	SliceU16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint16, error)

	// SliceI32 gets the i32 column for all rows that match the 'where' condition.
	SliceI32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int32, error)

	// SliceU32 gets the u32 column for all rows that match the 'where' condition.
	SliceU32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint32, error)

	// SliceI64 gets the i64 column for all rows that match the 'where' condition.
	SliceI64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceU64 gets the u64 column for all rows that match the 'where' condition.
	SliceU64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint64, error)

	// SliceRole gets the role column for all rows that match the 'where' condition.
	SliceRole(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Role, error)

	// SliceF32 gets the f32 column for all rows that match the 'where' condition.
	SliceF32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float32, error)

	// SliceF64 gets the f64 column for all rows that match the 'where' condition.
	SliceF64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float64, error)

	// Insert adds new records for the Users, setting the primary key field for each one.
	Insert(req require.Requirement, vv ...*User) error

	// Update updates records, matching them by primary key.
	Update(req require.Requirement, vv ...*User) (int64, error)
}

AUserTabler lists methods provided by AUserTable.

type Address added in v0.12.0

type Address struct {
	Id int64 `sql:"pk: true, auto: true"`
	AddressFields
}

func ScanAddresses added in v0.50.0

func ScanAddresses(query string, rows sqlapi.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 AddressFields added in v0.53.0

type AddressFields struct {
	Lines    []string `sql:"encode: json"`
	Town     *string  `sql:"size: 80, index: townIdx"`
	Postcode string   `sql:"size: 20, index: postcodeIdx"`
}

type AddressTable added in v0.12.0

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 added in v0.12.0

func CopyTableAsAddressTable(origin sqlapi.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 added in v0.12.0

func NewAddressTable(name string, d sqlapi.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) Constraints added in v0.14.0

func (tbl AddressTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (AddressTable) Count added in v0.12.0

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 added in v0.12.0

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 added in v0.12.0

func (tbl AddressTable) CreateIndexes(ifNotExist bool) (err error)

CreateIndexes executes queries that create the indexes needed by the Address table.

func (AddressTable) CreatePostcodeIdxIndex added in v0.12.0

func (tbl AddressTable) CreatePostcodeIdxIndex(ifNotExist bool) error

CreatePostcodeIdxIndex creates the postcodeIdx index.

func (AddressTable) CreateTable added in v0.12.0

func (tbl AddressTable) CreateTable(ifNotExists bool) (int64, error)

CreateTable creates the table.

func (AddressTable) CreateTableWithIndexes added in v0.12.0

func (tbl AddressTable) CreateTableWithIndexes(ifNotExist bool) (err error)

CreateTableWithIndexes invokes CreateTable then CreateIndexes.

func (AddressTable) CreateTownIdxIndex added in v0.16.0

func (tbl AddressTable) CreateTownIdxIndex(ifNotExist bool) error

CreateTownIdxIndex creates the townIdx index.

func (AddressTable) Ctx added in v0.12.0

func (tbl AddressTable) Ctx() context.Context

Ctx gets the current request context.

func (AddressTable) DB added in v0.12.0

func (tbl AddressTable) DB() sqlapi.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 added in v0.12.0

func (tbl AddressTable) Database() sqlapi.Database

Database gets the shared database information.

func (AddressTable) Delete added in v0.12.0

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 added in v0.12.0

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 added in v0.12.0

func (tbl AddressTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (AddressTable) DropIndexes added in v0.12.0

func (tbl AddressTable) DropIndexes(ifExist bool) (err error)

DropIndexes executes queries that drop the indexes on by the Address table.

func (AddressTable) DropPostcodeIdxIndex added in v0.12.0

func (tbl AddressTable) DropPostcodeIdxIndex(ifExists bool) error

DropPostcodeIdxIndex drops the postcodeIdx index.

func (AddressTable) DropTable added in v0.12.0

func (tbl AddressTable) DropTable(ifExists bool) (int64, error)

DropTable drops the table, destroying all its data.

func (AddressTable) DropTownIdxIndex added in v0.16.0

func (tbl AddressTable) DropTownIdxIndex(ifExists bool) error

DropTownIdxIndex drops the townIdx index.

func (AddressTable) Exec added in v0.12.0

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 added in v0.12.0

func (tbl AddressTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (AddressTable) Fetch added in v0.17.0

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 added in v0.16.0

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 added in v0.16.0

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 added in v0.16.0

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 added in v0.16.0

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 added in v0.12.0

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 added in v0.12.0

func (tbl AddressTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (AddressTable) Logger added in v0.12.0

func (tbl AddressTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (AddressTable) Name added in v0.12.0

func (tbl AddressTable) Name() sqlapi.TableName

Name gets the table name.

func (AddressTable) PkColumn added in v0.25.0

func (tbl AddressTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (AddressTable) Query added in v0.12.0

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 *sqlapi.Rows if you need to access its data as a map.

func (AddressTable) QueryOneNullFloat64 added in v0.12.0

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 added in v0.12.0

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 added in v0.12.0

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 added in v0.12.0

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 added in v0.12.0

SelectOne allows a single Address to be obtained from the table that matches 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. 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 added in v0.12.0

func (tbl AddressTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Address, error)

SelectOneWhere allows a single Address to be obtained from the table that matches 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 added in v0.12.0

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) SliceId added in v0.12.0

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 added in v0.12.0

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 added in v0.16.0

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) Transact added in v0.51.0

func (tbl AddressTable) Transact(txOptions *sql.TxOptions, fn func(AddressTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (AddressTable) Truncate added in v0.12.0

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 added in v0.12.0

func (tbl AddressTable) Tx() sqlapi.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 added in v0.12.0

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 added in v0.12.0

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 added in v0.49.0

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 added in v0.12.0

func (tbl AddressTable) Using(tx sqlapi.SqlTx) AddressTabler

Using returns a modified AddressTabler 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 added in v0.12.0

func (tbl AddressTable) WithConstraint(cc ...constraint.Constraint) AddressTabler

WithConstraint returns a modified AddressTabler with added data consistency constraints.

func (AddressTable) WithContext added in v0.12.0

func (tbl AddressTable) WithContext(ctx context.Context) AddressTabler

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 added in v0.12.0

func (tbl AddressTable) WithPrefix(pfx string) AddressTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type AddressTabler added in v0.53.0

type AddressTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified AddressTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) AddressTabler

	// WithPrefix returns a modified AddressTabler with a given table name prefix.
	WithPrefix(pfx string) AddressTabler

	// WithContext returns a modified AddressTabler with a given context.
	WithContext(ctx context.Context) AddressTabler

	// Using returns a modified AddressTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) AddressTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(AddressTabler) error) error

	// CreateTable creates the table.
	CreateTable(ifNotExists bool) (int64, error)

	// DropTable drops the table, destroying all its data.
	DropTable(ifExists bool) (int64, error)

	// CreateTableWithIndexes invokes CreateTable then CreateIndexes.
	CreateTableWithIndexes(ifNotExist bool) (err error)

	// CreateIndexes executes queries that create the indexes needed by the Address table.
	CreateIndexes(ifNotExist bool) (err error)

	// CreatePostcodeIdxIndex creates the postcodeIdx index.
	CreatePostcodeIdxIndex(ifNotExist bool) error

	// DropPostcodeIdxIndex drops the postcodeIdx index.
	DropPostcodeIdxIndex(ifExists bool) error

	// CreateTownIdxIndex creates the townIdx index.
	CreateTownIdxIndex(ifNotExist bool) error

	// DropTownIdxIndex drops the townIdx index.
	DropTownIdxIndex(ifExists bool) error

	// Truncate drops every record from the table, if possible.
	Truncate(force bool) (err error)

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for Address values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*Address, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

	// GetAddressesById gets records from the table according to a list of primary keys.
	GetAddressesById(req require.Requirement, id ...int64) (list []*Address, err error)

	// GetAddressById gets the record with a given primary key value.
	GetAddressById(req require.Requirement, id int64) (*Address, error)

	// GetAddressesByPostcode gets the records with a given postcode value.
	GetAddressesByPostcode(req require.Requirement, postcode string) ([]*Address, error)

	// GetAddressesByTown gets the records with a given town value.
	GetAddressesByTown(req require.Requirement, town string) ([]*Address, error)

	// SelectOneWhere allows a single Address to be obtained from the table that matches a 'where' clause.
	SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Address, error)

	// SelectOne allows a single Address to be obtained from the table that matches a 'where' clause.
	SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*Address, error)

	// SelectWhere allows Addresses to be obtained from the table that match a 'where' clause.
	SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Address, error)

	// Select allows Addresses to be obtained from the table that match a 'where' clause.
	Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*Address, error)

	// CountWhere counts Addresses in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Addresses in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)

	// SliceId gets the id column for all rows that match the 'where' condition.
	SliceId(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceTown gets the town column for all rows that match the 'where' condition.
	SliceTown(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SlicePostcode gets the postcode column for all rows that match the 'where' condition.
	SlicePostcode(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// Insert adds new records for the Addresses, setting the primary key field for each one.
	Insert(req require.Requirement, vv ...*Address) error

	// Update updates records, matching them by primary key.
	Update(req require.Requirement, vv ...*Address) (int64, error)
}

AddressTabler lists methods provided by AddressTable.

type Association

type Association struct {
	Id       int64 `sql:"pk: true, auto: true"`
	Name     *string
	Quality  *QualName
	Ref1     *int64
	Ref2     *int64
	Category *Category
}

func ScanAssociations added in v0.50.0

func ScanAssociations(query string, rows sqlapi.SqlRows, firstOnly bool) (vv []*Association, n int64, err error)

ScanAssociations 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 AssociationTable

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

AssociationTable 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 CopyTableAsAssociationTable added in v0.8.0

func CopyTableAsAssociationTable(origin sqlapi.Table) AssociationTable

CopyTableAsAssociationTable copies a table instance, retaining the name etc but providing methods appropriate for 'Association'. It doesn't copy the constraints of the original table.

It serves to provide methods appropriate for 'Association'. 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 NewAssociationTable

func NewAssociationTable(name string, d sqlapi.Database) AssociationTable

NewAssociationTable returns a new table instance. If a blank table name is supplied, the default name "associations" will be used instead. The request context is initialised with the background.

func (AssociationTable) Constraints added in v0.14.0

func (tbl AssociationTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (AssociationTable) Count

func (tbl AssociationTable) Count(wh where.Expression) (count int64, err error)

Count counts the Associations in the table that match a 'where' clause. Use a nil value for the 'wh' argument if it is not needed.

func (AssociationTable) CountWhere added in v0.9.0

func (tbl AssociationTable) CountWhere(where string, args ...interface{}) (count int64, err error)

CountWhere counts Associations 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 (AssociationTable) CreateTable

func (tbl AssociationTable) CreateTable(ifNotExists bool) (int64, error)

CreateTable creates the table.

func (AssociationTable) Ctx

func (tbl AssociationTable) Ctx() context.Context

Ctx gets the current request context.

func (AssociationTable) DB

func (tbl AssociationTable) DB() sqlapi.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 (AssociationTable) Database added in v0.12.0

func (tbl AssociationTable) Database() sqlapi.Database

Database gets the shared database information.

func (AssociationTable) Delete

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 (AssociationTable) DeleteAssociations added in v0.8.0

func (tbl AssociationTable) DeleteAssociations(req require.Requirement, id ...int64) (int64, error)

DeleteAssociations deletes rows from the table, given some primary keys. The list of ids can be arbitrarily long.

func (AssociationTable) Dialect

func (tbl AssociationTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (AssociationTable) DropTable

func (tbl AssociationTable) DropTable(ifExists bool) (int64, error)

DropTable drops the table, destroying all its data.

func (AssociationTable) Exec

func (tbl AssociationTable) 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 (AssociationTable) Execer added in v0.12.0

func (tbl AssociationTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (AssociationTable) Fetch added in v0.17.0

func (tbl AssociationTable) Fetch(req require.Requirement, query string, args ...interface{}) ([]*Association, error)

Fetch fetches a list of Association based on a supplied query. This is mostly used for join queries that map its result columns to the fields of Association. Other queries might be better handled by GetXxx or Select methods.

func (AssociationTable) GetAssociationById added in v0.16.0

func (tbl AssociationTable) GetAssociationById(req require.Requirement, id int64) (*Association, error)

GetAssociationById gets the record with a given primary key value. If not found, *Association will be nil.

func (AssociationTable) GetAssociationsById added in v0.16.0

func (tbl AssociationTable) GetAssociationsById(req require.Requirement, id ...int64) (list []*Association, err error)

GetAssociationsById 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 (AssociationTable) Insert

func (tbl AssociationTable) Insert(req require.Requirement, vv ...*Association) error

Insert adds new records for the Associations.// The Associations have their primary key fields set to the new record identifiers. The Association.PreInsert() method will be called, if it exists.

func (AssociationTable) IsTx

func (tbl AssociationTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (AssociationTable) Logger

func (tbl AssociationTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (AssociationTable) Name

func (tbl AssociationTable) Name() sqlapi.TableName

Name gets the table name.

func (AssociationTable) PkColumn added in v0.25.0

func (tbl AssociationTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (AssociationTable) Query

func (tbl AssociationTable) Query(req require.Requirement, query string, args ...interface{}) ([]*Association, error)

Query is the low-level request method for this table. The SQL query must return all the columns necessary for Association 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 *sqlapi.Rows if you need to access its data as a map.

func (AssociationTable) QueryOneNullFloat64 added in v0.9.0

func (tbl AssociationTable) 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 (AssociationTable) QueryOneNullInt64 added in v0.9.0

func (tbl AssociationTable) 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 (AssociationTable) QueryOneNullString added in v0.9.0

func (tbl AssociationTable) 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 (AssociationTable) Select

Select allows Associations 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 (AssociationTable) SelectOne

SelectOne allows a single Association to be obtained from the table that matches 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. 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 (AssociationTable) SelectOneWhere added in v0.9.0

func (tbl AssociationTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Association, error)

SelectOneWhere allows a single Association to be obtained from the table that matches 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 (AssociationTable) SelectWhere added in v0.9.0

func (tbl AssociationTable) SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Association, error)

SelectWhere allows Associations 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 (AssociationTable) SliceCategory

SliceCategory gets the category 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 (AssociationTable) SliceId

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 (AssociationTable) SliceName

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 (AssociationTable) SliceQuality

SliceQuality gets the quality 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 (AssociationTable) SliceRef1

SliceRef1 gets the ref1 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 (AssociationTable) SliceRef2

SliceRef2 gets the ref2 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 (AssociationTable) Transact added in v0.51.0

func (tbl AssociationTable) Transact(txOptions *sql.TxOptions, fn func(AssociationTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (AssociationTable) Truncate

func (tbl AssociationTable) 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 (AssociationTable) Tx

func (tbl AssociationTable) Tx() sqlapi.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 (AssociationTable) Update

func (tbl AssociationTable) Update(req require.Requirement, vv ...*Association) (int64, error)

Update updates records, matching them by primary key. It returns the number of rows affected. The Association.PreUpdate(Execer) method will be called, if it exists.

func (AssociationTable) UpdateFields

func (tbl AssociationTable) 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 (AssociationTable) Upsert added in v0.49.0

func (tbl AssociationTable) Upsert(v *Association, 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 (AssociationTable) Using added in v0.9.0

Using returns a modified AssociationTabler 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 (AssociationTable) WithConstraint added in v0.12.0

func (tbl AssociationTable) WithConstraint(cc ...constraint.Constraint) AssociationTabler

WithConstraint returns a modified AssociationTabler with added data consistency constraints.

func (AssociationTable) WithContext

func (tbl AssociationTable) WithContext(ctx context.Context) AssociationTabler

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 (AssociationTable) WithPrefix

func (tbl AssociationTable) WithPrefix(pfx string) AssociationTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type AssociationTabler added in v0.53.0

type AssociationTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified AssociationTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) AssociationTabler

	// WithPrefix returns a modified AssociationTabler with a given table name prefix.
	WithPrefix(pfx string) AssociationTabler

	// WithContext returns a modified AssociationTabler with a given context.
	WithContext(ctx context.Context) AssociationTabler

	// Using returns a modified AssociationTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) AssociationTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(AssociationTabler) error) error

	// CreateTable creates the table.
	CreateTable(ifNotExists bool) (int64, error)

	// DropTable drops the table, destroying all its data.
	DropTable(ifExists bool) (int64, error)

	// Truncate drops every record from the table, if possible.
	Truncate(force bool) (err error)

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for Association values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*Association, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

	// GetAssociationsById gets records from the table according to a list of primary keys.
	GetAssociationsById(req require.Requirement, id ...int64) (list []*Association, err error)

	// GetAssociationById gets the record with a given primary key value.
	GetAssociationById(req require.Requirement, id int64) (*Association, error)

	// SelectOneWhere allows a single Association to be obtained from the table that matches a 'where' clause.
	SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Association, error)

	// SelectOne allows a single Association to be obtained from the table that matches a 'where' clause.
	SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*Association, error)

	// SelectWhere allows Associations to be obtained from the table that match a 'where' clause.
	SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Association, error)

	// Select allows Associations to be obtained from the table that match a 'where' clause.
	Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*Association, error)

	// CountWhere counts Associations in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Associations in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)

	// SliceId gets the id column for all rows that match the 'where' condition.
	SliceId(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceName gets the name column for all rows that match the 'where' condition.
	SliceName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceRef1 gets the ref1 column for all rows that match the 'where' condition.
	SliceRef1(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceRef2 gets the ref2 column for all rows that match the 'where' condition.
	SliceRef2(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceQuality gets the quality column for all rows that match the 'where' condition.
	SliceQuality(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]QualName, error)

	// SliceCategory gets the category column for all rows that match the 'where' condition.
	SliceCategory(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Category, error)

	// Insert adds new records for the Associations, setting the primary key field for each one.
	Insert(req require.Requirement, vv ...*Association) error

	// Update updates records, matching them by primary key.
	Update(req require.Requirement, vv ...*Association) (int64, error)
}

AssociationTabler lists methods provided by AssociationTable.

type Author

type Author struct {
	Name     string `sql:"prefixed: true"`
	Email    Email  `sql:"prefixed: true"`
	Username string `sql:"prefixed: true"`
}

type Bounds added in v0.49.0

type Bounds struct {
	After  string `sql:"size: 20"`
	Before string `sql:"size: 20"`
}

type CUserTable added in v0.8.0

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

CUserTable 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 CopyTableAsCUserTable added in v0.8.0

func CopyTableAsCUserTable(origin sqlapi.Table) CUserTable

CopyTableAsCUserTable 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 NewCUserTable added in v0.8.0

func NewCUserTable(name string, d sqlapi.Database) CUserTable

NewCUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (CUserTable) Constraints added in v0.14.0

func (tbl CUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (CUserTable) Count added in v0.49.0

func (tbl CUserTable) 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 (CUserTable) CountWhere added in v0.49.0

func (tbl CUserTable) 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 (CUserTable) Ctx added in v0.8.0

func (tbl CUserTable) Ctx() context.Context

Ctx gets the current request context.

func (CUserTable) DB added in v0.8.0

func (tbl CUserTable) DB() sqlapi.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 (CUserTable) Database added in v0.12.0

func (tbl CUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (CUserTable) Dialect added in v0.8.0

func (tbl CUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (CUserTable) Execer added in v0.12.0

func (tbl CUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (CUserTable) IsTx added in v0.8.0

func (tbl CUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (CUserTable) Logger added in v0.8.0

func (tbl CUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (CUserTable) Name added in v0.8.0

func (tbl CUserTable) Name() sqlapi.TableName

Name gets the table name.

func (CUserTable) PkColumn added in v0.25.0

func (tbl CUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (CUserTable) Transact added in v0.51.0

func (tbl CUserTable) Transact(txOptions *sql.TxOptions, fn func(CUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (CUserTable) Tx added in v0.8.0

func (tbl CUserTable) Tx() sqlapi.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 (CUserTable) Using added in v0.9.0

func (tbl CUserTable) Using(tx sqlapi.SqlTx) CUserTabler

Using returns a modified CUserTabler 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 (CUserTable) WithConstraint added in v0.12.0

func (tbl CUserTable) WithConstraint(cc ...constraint.Constraint) CUserTabler

WithConstraint returns a modified CUserTabler with added data consistency constraints.

func (CUserTable) WithContext added in v0.8.0

func (tbl CUserTable) WithContext(ctx context.Context) CUserTabler

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 (CUserTable) WithPrefix added in v0.8.0

func (tbl CUserTable) WithPrefix(pfx string) CUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type CUserTabler added in v0.53.0

type CUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified CUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) CUserTabler

	// WithPrefix returns a modified CUserTabler with a given table name prefix.
	WithPrefix(pfx string) CUserTabler

	// WithContext returns a modified CUserTabler with a given context.
	WithContext(ctx context.Context) CUserTabler

	// Using returns a modified CUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) CUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(CUserTabler) error) error

	// CountWhere counts Users in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Users in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)
}

CUserTabler lists methods provided by CUserTable.

type Category

type Category uint8
const (
	Alpha Category = iota
	Beta
	Gamma
	Delta
)

type Commit

type Commit struct {
	ID        string `sql:"name: commit_id"`
	Message   string
	Timestamp string
	Author    *Author
	Committer *Author
}

type Compound

type Compound struct {
	Alpha    string `sql:"unique: alpha_beta"`
	Beta     string `sql:"unique: alpha_beta"`
	Category Category
}

func ScanDbCompounds added in v0.50.0

func ScanDbCompounds(query string, rows sqlapi.SqlRows, firstOnly bool) (vv []*Compound, n int64, err error)

ScanDbCompounds 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 DUserTable added in v0.8.0

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

DUserTable 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 CopyTableAsDUserTable added in v0.8.0

func CopyTableAsDUserTable(origin sqlapi.Table) DUserTable

CopyTableAsDUserTable 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 NewDUserTable added in v0.8.0

func NewDUserTable(name string, d sqlapi.Database) DUserTable

NewDUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (DUserTable) Constraints added in v0.14.0

func (tbl DUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (DUserTable) Ctx added in v0.8.0

func (tbl DUserTable) Ctx() context.Context

Ctx gets the current request context.

func (DUserTable) DB added in v0.8.0

func (tbl DUserTable) DB() sqlapi.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 (DUserTable) Database added in v0.12.0

func (tbl DUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (DUserTable) Delete added in v0.8.0

func (tbl DUserTable) 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 (DUserTable) DeleteUsers added in v0.8.0

func (tbl DUserTable) 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 (DUserTable) Dialect added in v0.8.0

func (tbl DUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (DUserTable) Exec added in v0.8.0

func (tbl DUserTable) 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 (DUserTable) Execer added in v0.12.0

func (tbl DUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (DUserTable) IsTx added in v0.8.0

func (tbl DUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (DUserTable) Logger added in v0.8.0

func (tbl DUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (DUserTable) Name added in v0.8.0

func (tbl DUserTable) Name() sqlapi.TableName

Name gets the table name.

func (DUserTable) PkColumn added in v0.25.0

func (tbl DUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (DUserTable) Transact added in v0.51.0

func (tbl DUserTable) Transact(txOptions *sql.TxOptions, fn func(DUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (DUserTable) Tx added in v0.8.0

func (tbl DUserTable) Tx() sqlapi.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 (DUserTable) Using added in v0.9.0

func (tbl DUserTable) Using(tx sqlapi.SqlTx) DUserTabler

Using returns a modified DUserTabler 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 (DUserTable) WithConstraint added in v0.12.0

func (tbl DUserTable) WithConstraint(cc ...constraint.Constraint) DUserTabler

WithConstraint returns a modified DUserTabler with added data consistency constraints.

func (DUserTable) WithContext added in v0.8.0

func (tbl DUserTable) WithContext(ctx context.Context) DUserTabler

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 (DUserTable) WithPrefix added in v0.8.0

func (tbl DUserTable) WithPrefix(pfx string) DUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type DUserTabler added in v0.53.0

type DUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified DUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) DUserTabler

	// WithPrefix returns a modified DUserTabler with a given table name prefix.
	WithPrefix(pfx string) DUserTabler

	// WithContext returns a modified DUserTabler with a given context.
	WithContext(ctx context.Context) DUserTabler

	// Using returns a modified DUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) DUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(DUserTabler) error) error
}

DUserTabler lists methods provided by DUserTable.

type Date

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

type Dates

type Dates struct {
	Id      uint64          `sql:"pk: true, auto: true"`
	Integer date.Date       `sql:"type: integer"`
	String  date.DateString `sql:"type: text"`
}

func NewDates added in v0.49.0

func NewDates(d date.Date) *Dates

func ScanDatess added in v0.50.0

func ScanDatess(query string, rows sqlapi.SqlRows, firstOnly bool) (vv []*Dates, n int64, err error)

ScanDatess 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 DatesTable added in v0.49.0

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

DatesTable 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 CopyTableAsDatesTable added in v0.49.0

func CopyTableAsDatesTable(origin sqlapi.Table) DatesTable

CopyTableAsDatesTable copies a table instance, retaining the name etc but providing methods appropriate for 'Dates'. It doesn't copy the constraints of the original table.

It serves to provide methods appropriate for 'Dates'. 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 NewDatesTable added in v0.49.0

func NewDatesTable(name string, d sqlapi.Database) DatesTable

NewDatesTable returns a new table instance. If a blank table name is supplied, the default name "datess" will be used instead. The request context is initialised with the background.

func (DatesTable) Constraints added in v0.49.0

func (tbl DatesTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (DatesTable) Count added in v0.49.0

func (tbl DatesTable) Count(wh where.Expression) (count int64, err error)

Count counts the Datess in the table that match a 'where' clause. Use a nil value for the 'wh' argument if it is not needed.

func (DatesTable) CountWhere added in v0.49.0

func (tbl DatesTable) CountWhere(where string, args ...interface{}) (count int64, err error)

CountWhere counts Datess 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 (DatesTable) CreateTable added in v0.49.0

func (tbl DatesTable) CreateTable(ifNotExists bool) (int64, error)

CreateTable creates the table.

func (DatesTable) Ctx added in v0.49.0

func (tbl DatesTable) Ctx() context.Context

Ctx gets the current request context.

func (DatesTable) DB added in v0.49.0

func (tbl DatesTable) DB() sqlapi.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 (DatesTable) Database added in v0.49.0

func (tbl DatesTable) Database() sqlapi.Database

Database gets the shared database information.

func (DatesTable) Delete added in v0.49.0

func (tbl DatesTable) 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 (DatesTable) DeleteDatess added in v0.49.0

func (tbl DatesTable) DeleteDatess(req require.Requirement, id ...uint64) (int64, error)

DeleteDatess deletes rows from the table, given some primary keys. The list of ids can be arbitrarily long.

func (DatesTable) Dialect added in v0.49.0

func (tbl DatesTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (DatesTable) DropTable added in v0.49.0

func (tbl DatesTable) DropTable(ifExists bool) (int64, error)

DropTable drops the table, destroying all its data.

func (DatesTable) Exec added in v0.49.0

func (tbl DatesTable) 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 (DatesTable) Execer added in v0.49.0

func (tbl DatesTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (DatesTable) Fetch added in v0.49.0

func (tbl DatesTable) Fetch(req require.Requirement, query string, args ...interface{}) ([]*Dates, error)

Fetch fetches a list of Dates based on a supplied query. This is mostly used for join queries that map its result columns to the fields of Dates. Other queries might be better handled by GetXxx or Select methods.

func (DatesTable) GetDatesById added in v0.49.0

func (tbl DatesTable) GetDatesById(req require.Requirement, id uint64) (*Dates, error)

GetDatesById gets the record with a given primary key value. If not found, *Dates will be nil.

func (DatesTable) GetDatessById added in v0.49.0

func (tbl DatesTable) GetDatessById(req require.Requirement, id ...uint64) (list []*Dates, err error)

GetDatessById 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 (DatesTable) Insert added in v0.49.0

func (tbl DatesTable) Insert(req require.Requirement, vv ...*Dates) error

Insert adds new records for the Datess.// The Datess have their primary key fields set to the new record identifiers. The Dates.PreInsert() method will be called, if it exists.

func (DatesTable) IsTx added in v0.49.0

func (tbl DatesTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (DatesTable) Logger added in v0.49.0

func (tbl DatesTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (DatesTable) Name added in v0.49.0

func (tbl DatesTable) Name() sqlapi.TableName

Name gets the table name.

func (DatesTable) PkColumn added in v0.49.0

func (tbl DatesTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (DatesTable) Query added in v0.49.0

func (tbl DatesTable) Query(req require.Requirement, query string, args ...interface{}) ([]*Dates, error)

Query is the low-level request method for this table. The SQL query must return all the columns necessary for Dates 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 *sqlapi.Rows if you need to access its data as a map.

func (DatesTable) QueryOneNullFloat64 added in v0.49.0

func (tbl DatesTable) 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 (DatesTable) QueryOneNullInt64 added in v0.49.0

func (tbl DatesTable) 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 (DatesTable) QueryOneNullString added in v0.49.0

func (tbl DatesTable) 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 (DatesTable) Select added in v0.49.0

Select allows Datess 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 (DatesTable) SelectOne added in v0.49.0

SelectOne allows a single Dates to be obtained from the table that matches 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. 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 (DatesTable) SelectOneWhere added in v0.49.0

func (tbl DatesTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Dates, error)

SelectOneWhere allows a single Dates to be obtained from the table that matches 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 (DatesTable) SelectWhere added in v0.49.0

func (tbl DatesTable) SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Dates, error)

SelectWhere allows Datess 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 (DatesTable) SliceId added in v0.49.0

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 (DatesTable) SliceInteger added in v0.49.0

func (tbl DatesTable) SliceInteger(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]date.Date, error)

SliceInteger gets the integer 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 (DatesTable) SliceString added in v0.49.0

SliceString gets the string 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 (DatesTable) Transact added in v0.51.0

func (tbl DatesTable) Transact(txOptions *sql.TxOptions, fn func(DatesTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (DatesTable) Truncate added in v0.49.0

func (tbl DatesTable) 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 (DatesTable) Tx added in v0.49.0

func (tbl DatesTable) Tx() sqlapi.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 (DatesTable) Update added in v0.49.0

func (tbl DatesTable) Update(req require.Requirement, vv ...*Dates) (int64, error)

Update updates records, matching them by primary key. It returns the number of rows affected. The Dates.PreUpdate(Execer) method will be called, if it exists.

func (DatesTable) UpdateFields added in v0.49.0

func (tbl DatesTable) 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 (DatesTable) Upsert added in v0.49.0

func (tbl DatesTable) Upsert(v *Dates, 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 (DatesTable) Using added in v0.49.0

func (tbl DatesTable) Using(tx sqlapi.SqlTx) DatesTabler

Using returns a modified DatesTabler 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 (DatesTable) WithConstraint added in v0.49.0

func (tbl DatesTable) WithConstraint(cc ...constraint.Constraint) DatesTabler

WithConstraint returns a modified DatesTabler with added data consistency constraints.

func (DatesTable) WithContext added in v0.49.0

func (tbl DatesTable) WithContext(ctx context.Context) DatesTabler

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 (DatesTable) WithPrefix added in v0.49.0

func (tbl DatesTable) WithPrefix(pfx string) DatesTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type DatesTabler added in v0.53.0

type DatesTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified DatesTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) DatesTabler

	// WithPrefix returns a modified DatesTabler with a given table name prefix.
	WithPrefix(pfx string) DatesTabler

	// WithContext returns a modified DatesTabler with a given context.
	WithContext(ctx context.Context) DatesTabler

	// Using returns a modified DatesTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) DatesTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(DatesTabler) error) error

	// CreateTable creates the table.
	CreateTable(ifNotExists bool) (int64, error)

	// DropTable drops the table, destroying all its data.
	DropTable(ifExists bool) (int64, error)

	// Truncate drops every record from the table, if possible.
	Truncate(force bool) (err error)

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for Dates values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*Dates, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

	// GetDatessById gets records from the table according to a list of primary keys.
	GetDatessById(req require.Requirement, id ...uint64) (list []*Dates, err error)

	// GetDatesById gets the record with a given primary key value.
	GetDatesById(req require.Requirement, id uint64) (*Dates, error)

	// SelectOneWhere allows a single Dates to be obtained from the table that matches a 'where' clause.
	SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Dates, error)

	// SelectOne allows a single Dates to be obtained from the table that matches a 'where' clause.
	SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*Dates, error)

	// SelectWhere allows Datess to be obtained from the table that match a 'where' clause.
	SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Dates, error)

	// Select allows Datess to be obtained from the table that match a 'where' clause.
	Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*Dates, error)

	// CountWhere counts Datess in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Datess in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)

	// SliceId gets the id column for all rows that match the 'where' condition.
	SliceId(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint64, error)

	// SliceInteger gets the integer column for all rows that match the 'where' condition.
	SliceInteger(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]date.Date, error)

	// SliceString gets the string column for all rows that match the 'where' condition.
	SliceString(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]date.DateString, error)

	// Insert adds new records for the Datess, setting the primary key field for each one.
	Insert(req require.Requirement, vv ...*Dates) error

	// Update updates records, matching them by primary key.
	Update(req require.Requirement, vv ...*Dates) (int64, error)
}

DatesTabler lists methods provided by DatesTable.

type DbCompoundTable

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

DbCompoundTable 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 CopyTableAsDbCompoundTable added in v0.8.0

func CopyTableAsDbCompoundTable(origin sqlapi.Table) DbCompoundTable

CopyTableAsDbCompoundTable copies a table instance, retaining the name etc but providing methods appropriate for 'Compound'. It doesn't copy the constraints of the original table.

It serves to provide methods appropriate for 'Compound'. 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 NewDbCompoundTable

func NewDbCompoundTable(name string, d sqlapi.Database) DbCompoundTable

NewDbCompoundTable returns a new table instance. If a blank table name is supplied, the default name "compounds" will be used instead. The request context is initialised with the background.

func (DbCompoundTable) Constraints added in v0.14.0

func (tbl DbCompoundTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (DbCompoundTable) Count

func (tbl DbCompoundTable) Count(wh where.Expression) (count int64, err error)

Count counts the Compounds in the table that match a 'where' clause. Use a nil value for the 'wh' argument if it is not needed.

func (DbCompoundTable) CountWhere added in v0.9.0

func (tbl DbCompoundTable) CountWhere(where string, args ...interface{}) (count int64, err error)

CountWhere counts Compounds 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 (DbCompoundTable) CreateAlphaBetaIndex

func (tbl DbCompoundTable) CreateAlphaBetaIndex(ifNotExist bool) error

CreateAlphaBetaIndex creates the alpha_beta index.

func (DbCompoundTable) CreateIndexes

func (tbl DbCompoundTable) CreateIndexes(ifNotExist bool) (err error)

CreateIndexes executes queries that create the indexes needed by the Compound table.

func (DbCompoundTable) CreateTable

func (tbl DbCompoundTable) CreateTable(ifNotExists bool) (int64, error)

CreateTable creates the table.

func (DbCompoundTable) CreateTableWithIndexes

func (tbl DbCompoundTable) CreateTableWithIndexes(ifNotExist bool) (err error)

CreateTableWithIndexes invokes CreateTable then CreateIndexes.

func (DbCompoundTable) Ctx

func (tbl DbCompoundTable) Ctx() context.Context

Ctx gets the current request context.

func (DbCompoundTable) DB

func (tbl DbCompoundTable) DB() sqlapi.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 (DbCompoundTable) Database added in v0.12.0

func (tbl DbCompoundTable) Database() sqlapi.Database

Database gets the shared database information.

func (DbCompoundTable) Delete

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 (DbCompoundTable) Dialect

func (tbl DbCompoundTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (DbCompoundTable) DropAlphaBetaIndex

func (tbl DbCompoundTable) DropAlphaBetaIndex(ifExists bool) error

DropAlphaBetaIndex drops the alpha_beta index.

func (DbCompoundTable) DropIndexes

func (tbl DbCompoundTable) DropIndexes(ifExist bool) (err error)

DropIndexes executes queries that drop the indexes on by the Compound table.

func (DbCompoundTable) DropTable

func (tbl DbCompoundTable) DropTable(ifExists bool) (int64, error)

DropTable drops the table, destroying all its data.

func (DbCompoundTable) Exec

func (tbl DbCompoundTable) 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 (DbCompoundTable) Execer added in v0.12.0

func (tbl DbCompoundTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (DbCompoundTable) Fetch added in v0.17.0

func (tbl DbCompoundTable) Fetch(req require.Requirement, query string, args ...interface{}) ([]*Compound, error)

Fetch fetches a list of Compound based on a supplied query. This is mostly used for join queries that map its result columns to the fields of Compound. Other queries might be better handled by GetXxx or Select methods.

func (DbCompoundTable) GetCompoundByAlphaAndBeta added in v0.21.0

func (tbl DbCompoundTable) GetCompoundByAlphaAndBeta(req require.Requirement, alpha string, beta string) (*Compound, error)

GetCompoundByAlphaAndBeta gets the record with given alpha+beta values. If not found, *Compound will be nil.

func (DbCompoundTable) Insert

func (tbl DbCompoundTable) Insert(req require.Requirement, vv ...*Compound) error

Insert adds new records for the Compounds. The Compound.PreInsert() method will be called, if it exists.

func (DbCompoundTable) IsTx

func (tbl DbCompoundTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (DbCompoundTable) Logger

func (tbl DbCompoundTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (DbCompoundTable) Name

func (tbl DbCompoundTable) Name() sqlapi.TableName

Name gets the table name.

func (DbCompoundTable) Query

func (tbl DbCompoundTable) Query(req require.Requirement, query string, args ...interface{}) ([]*Compound, error)

Query is the low-level request method for this table. The SQL query must return all the columns necessary for Compound 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 *sqlapi.Rows if you need to access its data as a map.

func (DbCompoundTable) QueryOneNullFloat64 added in v0.9.0

func (tbl DbCompoundTable) 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 (DbCompoundTable) QueryOneNullInt64 added in v0.9.0

func (tbl DbCompoundTable) 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 (DbCompoundTable) QueryOneNullString added in v0.9.0

func (tbl DbCompoundTable) 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 (DbCompoundTable) Select

Select allows Compounds 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 (DbCompoundTable) SelectOne

SelectOne allows a single Compound to be obtained from the table that matches 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. 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 (DbCompoundTable) SelectOneWhere added in v0.9.0

func (tbl DbCompoundTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Compound, error)

SelectOneWhere allows a single Compound to be obtained from the table that matches 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 (DbCompoundTable) SelectWhere added in v0.9.0

func (tbl DbCompoundTable) SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Compound, error)

SelectWhere allows Compounds 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 (DbCompoundTable) SliceAlpha

SliceAlpha gets the alpha 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 (DbCompoundTable) SliceBeta

SliceBeta gets the beta 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 (DbCompoundTable) SliceCategory

SliceCategory gets the category 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 (DbCompoundTable) Transact added in v0.51.0

func (tbl DbCompoundTable) Transact(txOptions *sql.TxOptions, fn func(DbCompoundTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (DbCompoundTable) Truncate

func (tbl DbCompoundTable) 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 (DbCompoundTable) Tx

func (tbl DbCompoundTable) Tx() sqlapi.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 (DbCompoundTable) UpdateFields

func (tbl DbCompoundTable) 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 (DbCompoundTable) Using added in v0.9.0

Using returns a modified DbCompoundTabler 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 (DbCompoundTable) WithConstraint added in v0.12.0

func (tbl DbCompoundTable) WithConstraint(cc ...constraint.Constraint) DbCompoundTabler

WithConstraint returns a modified DbCompoundTabler with added data consistency constraints.

func (DbCompoundTable) WithContext

func (tbl DbCompoundTable) WithContext(ctx context.Context) DbCompoundTabler

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 (DbCompoundTable) WithPrefix

func (tbl DbCompoundTable) WithPrefix(pfx string) DbCompoundTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type DbCompoundTabler added in v0.53.0

type DbCompoundTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified DbCompoundTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) DbCompoundTabler

	// WithPrefix returns a modified DbCompoundTabler with a given table name prefix.
	WithPrefix(pfx string) DbCompoundTabler

	// WithContext returns a modified DbCompoundTabler with a given context.
	WithContext(ctx context.Context) DbCompoundTabler

	// Using returns a modified DbCompoundTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) DbCompoundTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(DbCompoundTabler) error) error

	// CreateTable creates the table.
	CreateTable(ifNotExists bool) (int64, error)

	// DropTable drops the table, destroying all its data.
	DropTable(ifExists bool) (int64, error)

	// CreateTableWithIndexes invokes CreateTable then CreateIndexes.
	CreateTableWithIndexes(ifNotExist bool) (err error)

	// CreateIndexes executes queries that create the indexes needed by the Compound table.
	CreateIndexes(ifNotExist bool) (err error)

	// CreateAlphaBetaIndex creates the alpha_beta index.
	CreateAlphaBetaIndex(ifNotExist bool) error

	// DropAlphaBetaIndex drops the alpha_beta index.
	DropAlphaBetaIndex(ifExists bool) error

	// Truncate drops every record from the table, if possible.
	Truncate(force bool) (err error)

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for Compound values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*Compound, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

	// GetCompoundByAlphaAndBeta gets the record with given alpha+beta values.
	GetCompoundByAlphaAndBeta(req require.Requirement, alpha string, beta string) (*Compound, error)

	// SelectOneWhere allows a single Compound to be obtained from the table that matches a 'where' clause.
	SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Compound, error)

	// SelectOne allows a single Compound to be obtained from the table that matches a 'where' clause.
	SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*Compound, error)

	// SelectWhere allows Compounds to be obtained from the table that match a 'where' clause.
	SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Compound, error)

	// Select allows Compounds to be obtained from the table that match a 'where' clause.
	Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*Compound, error)

	// CountWhere counts Compounds in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Compounds in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)

	// SliceAlpha gets the alpha column for all rows that match the 'where' condition.
	SliceAlpha(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceBeta gets the beta column for all rows that match the 'where' condition.
	SliceBeta(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceCategory gets the category column for all rows that match the 'where' condition.
	SliceCategory(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Category, error)

	// Insert adds new records for the Compounds.
	Insert(req require.Requirement, vv ...*Compound) error
}

DbCompoundTabler lists methods provided by DbCompoundTable.

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 added in v0.8.0

func CopyTableAsDbUserTable(origin sqlapi.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 sqlapi.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) Constraints added in v0.14.0

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 added in v0.9.0

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 added in v0.16.0

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() sqlapi.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 added in v0.12.0

func (tbl DbUserTable) Database() sqlapi.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 added in v0.8.0

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 added in v0.16.0

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 added in v0.12.0

func (tbl DbUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (DbUserTable) Fetch added in v0.17.0

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 added in v0.16.0

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 added in v0.16.0

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 added in v0.16.0

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 added in v0.16.0

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() sqlapi.Logger

Logger gets the trace logger.

func (DbUserTable) Name

func (tbl DbUserTable) Name() sqlapi.TableName

Name gets the table name.

func (DbUserTable) PkColumn added in v0.25.0

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 *sqlapi.Rows if you need to access its data as a map.

func (DbUserTable) QueryOneNullFloat64 added in v0.9.0

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 added in v0.9.0

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 added in v0.9.0

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

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

SelectOne allows a single User to be obtained from the table that matches 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. 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 added in v0.9.0

func (tbl DbUserTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*User, error)

SelectOneWhere allows a single User to be obtained from the table that matches 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 added in v0.9.0

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) SliceAddressid added in v0.12.0

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 added in v0.8.0

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 added in v0.19.0

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 added in v0.19.0

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 added in v0.19.0

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 added in v0.19.0

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 added in v0.19.0

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 added in v0.19.0

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 added in v0.8.0

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 added in v0.16.0

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 added in v0.10.0

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 added in v0.19.0

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 added in v0.19.0

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 added in v0.19.0

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 added in v0.19.0

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

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) Transact added in v0.51.0

func (tbl DbUserTable) Transact(txOptions *sql.TxOptions, fn func(DbUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

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() sqlapi.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 added in v0.49.0

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 added in v0.9.0

func (tbl DbUserTable) Using(tx sqlapi.SqlTx) DbUserTabler

Using returns a modified DbUserTabler 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 added in v0.12.0

func (tbl DbUserTable) WithConstraint(cc ...constraint.Constraint) DbUserTabler

WithConstraint returns a modified DbUserTabler with added data consistency constraints.

func (DbUserTable) WithContext

func (tbl DbUserTable) WithContext(ctx context.Context) DbUserTabler

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

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type DbUserTabler added in v0.53.0

type DbUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified DbUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) DbUserTabler

	// WithPrefix returns a modified DbUserTabler with a given table name prefix.
	WithPrefix(pfx string) DbUserTabler

	// WithContext returns a modified DbUserTabler with a given context.
	WithContext(ctx context.Context) DbUserTabler

	// Using returns a modified DbUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) DbUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(DbUserTabler) error) error

	// CreateTable creates the table.
	CreateTable(ifNotExists bool) (int64, error)

	// DropTable drops the table, destroying all its data.
	DropTable(ifExists bool) (int64, error)

	// CreateTableWithIndexes invokes CreateTable then CreateIndexes.
	CreateTableWithIndexes(ifNotExist bool) (err error)

	// CreateIndexes executes queries that create the indexes needed by the User table.
	CreateIndexes(ifNotExist bool) (err error)

	// CreateEmailaddressIdxIndex creates the emailaddress_idx index.
	CreateEmailaddressIdxIndex(ifNotExist bool) error

	// DropEmailaddressIdxIndex drops the emailaddress_idx index.
	DropEmailaddressIdxIndex(ifExists bool) error

	// CreateUserLoginIndex creates the user_login index.
	CreateUserLoginIndex(ifNotExist bool) error

	// DropUserLoginIndex drops the user_login index.
	DropUserLoginIndex(ifExists bool) error

	// Truncate drops every record from the table, if possible.
	Truncate(force bool) (err error)

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for User values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*User, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

	// GetUsersByUid gets records from the table according to a list of primary keys.
	GetUsersByUid(req require.Requirement, id ...int64) (list []*User, err error)

	// GetUserByUid gets the record with a given primary key value.
	GetUserByUid(req require.Requirement, id int64) (*User, error)

	// GetUserByEmailAddress gets the record with a given emailaddress value.
	GetUserByEmailAddress(req require.Requirement, emailaddress string) (*User, error)

	// GetUserByName gets the record with a given name value.
	GetUserByName(req require.Requirement, name string) (*User, error)

	// SelectOneWhere allows a single User to be obtained from the table that matches a 'where' clause.
	SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*User, error)

	// SelectOne allows a single User to be obtained from the table that matches a 'where' clause.
	SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*User, error)

	// SelectWhere allows Users to be obtained from the table that match a 'where' clause.
	SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*User, error)

	// Select allows Users to be obtained from the table that match a 'where' clause.
	Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*User, error)

	// CountWhere counts Users in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Users in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)

	// SliceUid gets the uid column for all rows that match the 'where' condition.
	SliceUid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceName gets the name column for all rows that match the 'where' condition.
	SliceName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceEmailaddress gets the emailaddress column for all rows that match the 'where' condition.
	SliceEmailaddress(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceAddressid gets the addressid column for all rows that match the 'where' condition.
	SliceAddressid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceAvatar gets the avatar column for all rows that match the 'where' condition.
	SliceAvatar(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceLastupdated gets the lastupdated column for all rows that match the 'where' condition.
	SliceLastupdated(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceI8 gets the i8 column for all rows that match the 'where' condition.
	SliceI8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int8, error)

	// SliceU8 gets the u8 column for all rows that match the 'where' condition.
	SliceU8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint8, error)

	// SliceI16 gets the i16 column for all rows that match the 'where' condition.
	SliceI16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int16, error)

	// SliceU16 gets the u16 column for all rows that match the 'where' condition.
	SliceU16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint16, error)

	// SliceI32 gets the i32 column for all rows that match the 'where' condition.
	SliceI32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int32, error)

	// SliceU32 gets the u32 column for all rows that match the 'where' condition.
	SliceU32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint32, error)

	// SliceI64 gets the i64 column for all rows that match the 'where' condition.
	SliceI64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceU64 gets the u64 column for all rows that match the 'where' condition.
	SliceU64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint64, error)

	// SliceRole gets the role column for all rows that match the 'where' condition.
	SliceRole(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Role, error)

	// SliceF32 gets the f32 column for all rows that match the 'where' condition.
	SliceF32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float32, error)

	// SliceF64 gets the f64 column for all rows that match the 'where' condition.
	SliceF64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float64, error)

	// Insert adds new records for the Users, setting the primary key field for each one.
	Insert(req require.Requirement, vv ...*User) error

	// Update updates records, matching them by primary key.
	Update(req require.Requirement, vv ...*User) (int64, error)
}

DbUserTabler lists methods provided by DbUserTable.

type EUserTable added in v0.53.0

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

EUserTable 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 CopyTableAsEUserTable added in v0.53.0

func CopyTableAsEUserTable(origin sqlapi.Table) EUserTable

CopyTableAsEUserTable 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 NewEUserTable added in v0.53.0

func NewEUserTable(name string, d sqlapi.Database) EUserTable

NewEUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (EUserTable) Constraints added in v0.53.0

func (tbl EUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (EUserTable) Ctx added in v0.53.0

func (tbl EUserTable) Ctx() context.Context

Ctx gets the current request context.

func (EUserTable) DB added in v0.53.0

func (tbl EUserTable) DB() sqlapi.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 (EUserTable) Database added in v0.53.0

func (tbl EUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (EUserTable) Dialect added in v0.53.0

func (tbl EUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (EUserTable) Exec added in v0.53.0

func (tbl EUserTable) 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 (EUserTable) Execer added in v0.53.0

func (tbl EUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (EUserTable) IsTx added in v0.53.0

func (tbl EUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (EUserTable) Logger added in v0.53.0

func (tbl EUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (EUserTable) Name added in v0.53.0

func (tbl EUserTable) Name() sqlapi.TableName

Name gets the table name.

func (EUserTable) PkColumn added in v0.53.0

func (tbl EUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (EUserTable) Transact added in v0.53.0

func (tbl EUserTable) Transact(txOptions *sql.TxOptions, fn func(EUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (EUserTable) Tx added in v0.53.0

func (tbl EUserTable) Tx() sqlapi.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 (EUserTable) Using added in v0.53.0

func (tbl EUserTable) Using(tx sqlapi.SqlTx) EUserTabler

Using returns a modified EUserTabler 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 (EUserTable) WithConstraint added in v0.53.0

func (tbl EUserTable) WithConstraint(cc ...constraint.Constraint) EUserTabler

WithConstraint returns a modified EUserTabler with added data consistency constraints.

func (EUserTable) WithContext added in v0.53.0

func (tbl EUserTable) WithContext(ctx context.Context) EUserTabler

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 (EUserTable) WithPrefix added in v0.53.0

func (tbl EUserTable) WithPrefix(pfx string) EUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type EUserTabler added in v0.53.0

type EUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified EUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) EUserTabler

	// WithPrefix returns a modified EUserTabler with a given table name prefix.
	WithPrefix(pfx string) EUserTabler

	// WithContext returns a modified EUserTabler with a given context.
	WithContext(ctx context.Context) EUserTabler

	// Using returns a modified EUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) EUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(EUserTabler) error) error
}

EUserTabler lists methods provided by EUserTable.

type Email

type Email string

type Hook

type Hook struct {
	Id  uint64 `sql:"pk: true, auto: true"`
	Sha string
	Bounds
	Category   Category
	Created    bool
	Deleted    bool
	Forced     bool
	HeadCommit *Commit `sql:"name: head"`
}

type HookList

type HookList []*Hook

func ScanHooks added in v0.50.0

func ScanHooks(query string, rows sqlapi.SqlRows, firstOnly bool) (vv HookList, n int64, err error)

ScanHooks 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 HookTable

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

HookTable 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 CopyTableAsHookTable added in v0.8.0

func CopyTableAsHookTable(origin sqlapi.Table) HookTable

CopyTableAsHookTable copies a table instance, retaining the name etc but providing methods appropriate for 'Hook'. It doesn't copy the constraints of the original table.

It serves to provide methods appropriate for 'Hook'. 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 NewHookTable

func NewHookTable(name string, d sqlapi.Database) HookTable

NewHookTable returns a new table instance. If a blank table name is supplied, the default name "hooks" will be used instead. The request context is initialised with the background.

func (HookTable) Constraints added in v0.14.0

func (tbl HookTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (HookTable) Count

func (tbl HookTable) Count(wh where.Expression) (count int64, err error)

Count counts the Hooks in the table that match a 'where' clause. Use a nil value for the 'wh' argument if it is not needed.

func (HookTable) CountWhere added in v0.9.0

func (tbl HookTable) CountWhere(where string, args ...interface{}) (count int64, err error)

CountWhere counts Hooks 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 (HookTable) CreateTable

func (tbl HookTable) CreateTable(ifNotExists bool) (int64, error)

CreateTable creates the table.

func (HookTable) Ctx

func (tbl HookTable) Ctx() context.Context

Ctx gets the current request context.

func (HookTable) DB

func (tbl HookTable) DB() sqlapi.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 (HookTable) Database added in v0.12.0

func (tbl HookTable) Database() sqlapi.Database

Database gets the shared database information.

func (HookTable) Delete

func (tbl HookTable) 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 (HookTable) DeleteHooks added in v0.8.0

func (tbl HookTable) DeleteHooks(req require.Requirement, id ...uint64) (int64, error)

DeleteHooks deletes rows from the table, given some primary keys. The list of ids can be arbitrarily long.

func (HookTable) Dialect

func (tbl HookTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (HookTable) DropTable

func (tbl HookTable) DropTable(ifExists bool) (int64, error)

DropTable drops the table, destroying all its data.

func (HookTable) Exec

func (tbl HookTable) 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 (HookTable) Execer added in v0.12.0

func (tbl HookTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (HookTable) Fetch added in v0.17.0

func (tbl HookTable) Fetch(req require.Requirement, query string, args ...interface{}) (HookList, error)

Fetch fetches a list of Hook based on a supplied query. This is mostly used for join queries that map its result columns to the fields of Hook. Other queries might be better handled by GetXxx or Select methods.

func (HookTable) GetHookById added in v0.16.0

func (tbl HookTable) GetHookById(req require.Requirement, id uint64) (*Hook, error)

GetHookById gets the record with a given primary key value. If not found, *Hook will be nil.

func (HookTable) GetHooksById added in v0.16.0

func (tbl HookTable) GetHooksById(req require.Requirement, id ...uint64) (list HookList, err error)

GetHooksById 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 (HookTable) Insert

func (tbl HookTable) Insert(req require.Requirement, vv ...*Hook) error

Insert adds new records for the Hooks.// The Hooks have their primary key fields set to the new record identifiers. The Hook.PreInsert() method will be called, if it exists.

func (HookTable) IsTx

func (tbl HookTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (HookTable) Logger

func (tbl HookTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (HookTable) Name

func (tbl HookTable) Name() sqlapi.TableName

Name gets the table name.

func (HookTable) PkColumn added in v0.25.0

func (tbl HookTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (HookTable) Query

func (tbl HookTable) Query(req require.Requirement, query string, args ...interface{}) (HookList, error)

Query is the low-level request method for this table. The SQL query must return all the columns necessary for Hook 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 *sqlapi.Rows if you need to access its data as a map.

func (HookTable) QueryOneNullFloat64 added in v0.9.0

func (tbl HookTable) 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 (HookTable) QueryOneNullInt64 added in v0.9.0

func (tbl HookTable) 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 (HookTable) QueryOneNullString added in v0.9.0

func (tbl HookTable) 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 (HookTable) Select

Select allows Hooks 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 (HookTable) SelectOne

func (tbl HookTable) SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*Hook, error)

SelectOne allows a single Hook to be obtained from the table that matches 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. 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 (HookTable) SelectOneWhere added in v0.9.0

func (tbl HookTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Hook, error)

SelectOneWhere allows a single Hook to be obtained from the table that matches 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 (HookTable) SelectWhere added in v0.9.0

func (tbl HookTable) SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) (HookList, error)

SelectWhere allows Hooks 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 (HookTable) SliceAfter added in v0.8.0

func (tbl HookTable) SliceAfter(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceAfter gets the after 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 (HookTable) SliceBefore added in v0.8.0

func (tbl HookTable) SliceBefore(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceBefore gets the before 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 (HookTable) SliceCategory

func (tbl HookTable) SliceCategory(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Category, error)

SliceCategory gets the category 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 (HookTable) SliceCommitId added in v0.8.0

func (tbl HookTable) SliceCommitId(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceCommitId gets the commit_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 (HookTable) SliceHeadCommitAuthorEmail added in v0.8.0

func (tbl HookTable) SliceHeadCommitAuthorEmail(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Email, error)

SliceHeadCommitAuthorEmail gets the head_commit_author_email 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 (HookTable) SliceHeadCommitAuthorName added in v0.8.0

func (tbl HookTable) SliceHeadCommitAuthorName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceHeadCommitAuthorName gets the head_commit_author_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 (HookTable) SliceHeadCommitAuthorUsername added in v0.8.0

func (tbl HookTable) SliceHeadCommitAuthorUsername(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceHeadCommitAuthorUsername gets the head_commit_author_username 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 (HookTable) SliceHeadCommitCommitterEmail added in v0.8.0

func (tbl HookTable) SliceHeadCommitCommitterEmail(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Email, error)

SliceHeadCommitCommitterEmail gets the head_commit_committer_email 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 (HookTable) SliceHeadCommitCommitterName added in v0.8.0

func (tbl HookTable) SliceHeadCommitCommitterName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceHeadCommitCommitterName gets the head_commit_committer_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 (HookTable) SliceHeadCommitCommitterUsername added in v0.8.0

func (tbl HookTable) SliceHeadCommitCommitterUsername(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceHeadCommitCommitterUsername gets the head_commit_committer_username 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 (HookTable) SliceId

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 (HookTable) SliceMessage added in v0.8.0

func (tbl HookTable) SliceMessage(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceMessage gets the message 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 (HookTable) SliceSha

SliceSha gets the sha 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 (HookTable) SliceTimestamp added in v0.8.0

func (tbl HookTable) SliceTimestamp(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceTimestamp gets the timestamp 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 (HookTable) Transact added in v0.51.0

func (tbl HookTable) Transact(txOptions *sql.TxOptions, fn func(HookTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (HookTable) Truncate

func (tbl HookTable) 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 (HookTable) Tx

func (tbl HookTable) Tx() sqlapi.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 (HookTable) Update

func (tbl HookTable) Update(req require.Requirement, vv ...*Hook) (int64, error)

Update updates records, matching them by primary key. It returns the number of rows affected. The Hook.PreUpdate(Execer) method will be called, if it exists.

func (HookTable) UpdateFields

func (tbl HookTable) 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 (HookTable) Upsert added in v0.49.0

func (tbl HookTable) Upsert(v *Hook, 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 (HookTable) Using added in v0.9.0

func (tbl HookTable) Using(tx sqlapi.SqlTx) HookTabler

Using returns a modified HookTabler 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 (HookTable) WithConstraint added in v0.12.0

func (tbl HookTable) WithConstraint(cc ...constraint.Constraint) HookTabler

WithConstraint returns a modified HookTabler with added data consistency constraints.

func (HookTable) WithContext

func (tbl HookTable) WithContext(ctx context.Context) HookTabler

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 (HookTable) WithPrefix

func (tbl HookTable) WithPrefix(pfx string) HookTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type HookTabler added in v0.53.0

type HookTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified HookTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) HookTabler

	// WithPrefix returns a modified HookTabler with a given table name prefix.
	WithPrefix(pfx string) HookTabler

	// WithContext returns a modified HookTabler with a given context.
	WithContext(ctx context.Context) HookTabler

	// Using returns a modified HookTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) HookTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(HookTabler) error) error

	// CreateTable creates the table.
	CreateTable(ifNotExists bool) (int64, error)

	// DropTable drops the table, destroying all its data.
	DropTable(ifExists bool) (int64, error)

	// Truncate drops every record from the table, if possible.
	Truncate(force bool) (err error)

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for Hook values.
	Query(req require.Requirement, query string, args ...interface{}) (HookList, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

	// GetHooksById gets records from the table according to a list of primary keys.
	GetHooksById(req require.Requirement, id ...uint64) (list HookList, err error)

	// GetHookById gets the record with a given primary key value.
	GetHookById(req require.Requirement, id uint64) (*Hook, error)

	// SelectOneWhere allows a single Hook to be obtained from the table that matches a 'where' clause.
	SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Hook, error)

	// SelectOne allows a single Hook to be obtained from the table that matches a 'where' clause.
	SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*Hook, error)

	// SelectWhere allows Hooks to be obtained from the table that match a 'where' clause.
	SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) (HookList, error)

	// Select allows Hooks to be obtained from the table that match a 'where' clause.
	Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (HookList, error)

	// CountWhere counts Hooks in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Hooks in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)

	// SliceId gets the id column for all rows that match the 'where' condition.
	SliceId(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint64, error)

	// SliceSha gets the sha column for all rows that match the 'where' condition.
	SliceSha(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceAfter gets the after column for all rows that match the 'where' condition.
	SliceAfter(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceBefore gets the before column for all rows that match the 'where' condition.
	SliceBefore(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceCommitId gets the commit_id column for all rows that match the 'where' condition.
	SliceCommitId(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceMessage gets the message column for all rows that match the 'where' condition.
	SliceMessage(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceTimestamp gets the timestamp column for all rows that match the 'where' condition.
	SliceTimestamp(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceHeadCommitAuthorName gets the head_commit_author_name column for all rows that match the 'where' condition.
	SliceHeadCommitAuthorName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceHeadCommitAuthorUsername gets the head_commit_author_username column for all rows that match the 'where' condition.
	SliceHeadCommitAuthorUsername(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceHeadCommitCommitterName gets the head_commit_committer_name column for all rows that match the 'where' condition.
	SliceHeadCommitCommitterName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceHeadCommitCommitterUsername gets the head_commit_committer_username column for all rows that match the 'where' condition.
	SliceHeadCommitCommitterUsername(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceCategory gets the category column for all rows that match the 'where' condition.
	SliceCategory(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Category, error)

	// SliceHeadCommitAuthorEmail gets the head_commit_author_email column for all rows that match the 'where' condition.
	SliceHeadCommitAuthorEmail(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Email, error)

	// SliceHeadCommitCommitterEmail gets the head_commit_committer_email column for all rows that match the 'where' condition.
	SliceHeadCommitCommitterEmail(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Email, error)

	// Insert adds new records for the Hooks, setting the primary key field for each one.
	Insert(req require.Requirement, vv ...*Hook) error

	// Update updates records, matching them by primary key.
	Update(req require.Requirement, vv ...*Hook) (int64, error)
}

HookTabler lists methods provided by HookTable.

type IUserTable added in v0.49.0

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

IUserTable 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 CopyTableAsIUserTable added in v0.49.0

func CopyTableAsIUserTable(origin sqlapi.Table) IUserTable

CopyTableAsIUserTable 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 NewIUserTable added in v0.49.0

func NewIUserTable(name string, d sqlapi.Database) IUserTable

NewIUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (IUserTable) Constraints added in v0.49.0

func (tbl IUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (IUserTable) Ctx added in v0.49.0

func (tbl IUserTable) Ctx() context.Context

Ctx gets the current request context.

func (IUserTable) DB added in v0.49.0

func (tbl IUserTable) DB() sqlapi.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 (IUserTable) Database added in v0.49.0

func (tbl IUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (IUserTable) Dialect added in v0.49.0

func (tbl IUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (IUserTable) Execer added in v0.49.0

func (tbl IUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (IUserTable) Insert added in v0.49.0

func (tbl IUserTable) 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 (IUserTable) IsTx added in v0.49.0

func (tbl IUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (IUserTable) Logger added in v0.49.0

func (tbl IUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (IUserTable) Name added in v0.49.0

func (tbl IUserTable) Name() sqlapi.TableName

Name gets the table name.

func (IUserTable) PkColumn added in v0.49.0

func (tbl IUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (IUserTable) Transact added in v0.51.0

func (tbl IUserTable) Transact(txOptions *sql.TxOptions, fn func(IUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (IUserTable) Tx added in v0.49.0

func (tbl IUserTable) Tx() sqlapi.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 (IUserTable) Using added in v0.49.0

func (tbl IUserTable) Using(tx sqlapi.SqlTx) IUserTabler

Using returns a modified IUserTabler 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 (IUserTable) WithConstraint added in v0.49.0

func (tbl IUserTable) WithConstraint(cc ...constraint.Constraint) IUserTabler

WithConstraint returns a modified IUserTabler with added data consistency constraints.

func (IUserTable) WithContext added in v0.49.0

func (tbl IUserTable) WithContext(ctx context.Context) IUserTabler

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 (IUserTable) WithPrefix added in v0.49.0

func (tbl IUserTable) WithPrefix(pfx string) IUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type IUserTabler added in v0.53.0

type IUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified IUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) IUserTabler

	// WithPrefix returns a modified IUserTabler with a given table name prefix.
	WithPrefix(pfx string) IUserTabler

	// WithContext returns a modified IUserTabler with a given context.
	WithContext(ctx context.Context) IUserTabler

	// Using returns a modified IUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) IUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(IUserTabler) error) error

	// Insert adds new records for the Users, setting the primary key field for each one.
	Insert(req require.Requirement, vv ...*User) error
}

IUserTabler lists methods provided by IUserTable.

type Issue

type Issue struct {
	Id       int64 `sql:"pk: true, auto: true"`
	Number   int
	Date     Date
	Title    string   `sql:"size: 512"`
	Body     string   `sql:"size: 2048, name: bigbody"`
	Assignee string   `sql:"index: issue_assignee"`
	State    string   `sql:"size: 50"`
	Labels   []string `sql:"encode: json"`
	// contains filtered or unexported fields
}

func ScanIssues added in v0.50.0

func ScanIssues(query string, rows sqlapi.SqlRows, firstOnly bool) (vv []*Issue, n int64, err error)

ScanIssues 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 (*Issue) SetAssignee added in v0.8.0

func (v *Issue) SetAssignee(x string) *Issue

SetAssignee sets the Assignee field and returns the modified Issue.

func (*Issue) SetBody added in v0.8.0

func (v *Issue) SetBody(x string) *Issue

SetBody sets the Body field and returns the modified Issue.

func (*Issue) SetDate added in v0.8.0

func (v *Issue) SetDate(x Date) *Issue

SetDate sets the Date field and returns the modified Issue.

func (*Issue) SetId added in v0.8.0

func (v *Issue) SetId(x int64) *Issue

SetId sets the Id field and returns the modified Issue.

func (*Issue) SetLabels added in v0.8.0

func (v *Issue) SetLabels(x []string) *Issue

SetLabels sets the Labels field and returns the modified Issue.

func (*Issue) SetNumber added in v0.8.0

func (v *Issue) SetNumber(x int) *Issue

SetNumber sets the Number field and returns the modified Issue.

func (*Issue) SetState added in v0.8.0

func (v *Issue) SetState(x string) *Issue

SetState sets the State field and returns the modified Issue.

func (*Issue) SetTitle added in v0.8.0

func (v *Issue) SetTitle(x string) *Issue

SetTitle sets the Title field and returns the modified Issue.

type IssueTable

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

IssueTable 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 CopyTableAsIssueTable added in v0.8.0

func CopyTableAsIssueTable(origin sqlapi.Table) IssueTable

CopyTableAsIssueTable copies a table instance, retaining the name etc but providing methods appropriate for 'Issue'. It doesn't copy the constraints of the original table.

It serves to provide methods appropriate for 'Issue'. 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 NewIssueTable

func NewIssueTable(name string, d sqlapi.Database) IssueTable

NewIssueTable returns a new table instance. If a blank table name is supplied, the default name "issues" will be used instead. The request context is initialised with the background.

func (IssueTable) Constraints added in v0.14.0

func (tbl IssueTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (IssueTable) Count

func (tbl IssueTable) Count(wh where.Expression) (count int64, err error)

Count counts the Issues in the table that match a 'where' clause. Use a nil value for the 'wh' argument if it is not needed.

func (IssueTable) CountWhere added in v0.9.0

func (tbl IssueTable) CountWhere(where string, args ...interface{}) (count int64, err error)

CountWhere counts Issues 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 (IssueTable) CreateIndexes

func (tbl IssueTable) CreateIndexes(ifNotExist bool) (err error)

CreateIndexes executes queries that create the indexes needed by the Issue table.

func (IssueTable) CreateIssueAssigneeIndex

func (tbl IssueTable) CreateIssueAssigneeIndex(ifNotExist bool) error

CreateIssueAssigneeIndex creates the issue_assignee index.

func (IssueTable) CreateTable

func (tbl IssueTable) CreateTable(ifNotExists bool) (int64, error)

CreateTable creates the table.

func (IssueTable) CreateTableWithIndexes

func (tbl IssueTable) CreateTableWithIndexes(ifNotExist bool) (err error)

CreateTableWithIndexes invokes CreateTable then CreateIndexes.

func (IssueTable) Ctx

func (tbl IssueTable) Ctx() context.Context

Ctx gets the current request context.

func (IssueTable) DB

func (tbl IssueTable) DB() sqlapi.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 (IssueTable) Database added in v0.12.0

func (tbl IssueTable) Database() sqlapi.Database

Database gets the shared database information.

func (IssueTable) Delete

func (tbl IssueTable) 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 (IssueTable) DeleteIssues added in v0.8.0

func (tbl IssueTable) DeleteIssues(req require.Requirement, id ...int64) (int64, error)

DeleteIssues deletes rows from the table, given some primary keys. The list of ids can be arbitrarily long.

func (IssueTable) Dialect

func (tbl IssueTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (IssueTable) DropIndexes

func (tbl IssueTable) DropIndexes(ifExist bool) (err error)

DropIndexes executes queries that drop the indexes on by the Issue table.

func (IssueTable) DropIssueAssigneeIndex

func (tbl IssueTable) DropIssueAssigneeIndex(ifExists bool) error

DropIssueAssigneeIndex drops the issue_assignee index.

func (IssueTable) DropTable

func (tbl IssueTable) DropTable(ifExists bool) (int64, error)

DropTable drops the table, destroying all its data.

func (IssueTable) Exec

func (tbl IssueTable) 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 (IssueTable) Execer added in v0.12.0

func (tbl IssueTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (IssueTable) Fetch added in v0.17.0

func (tbl IssueTable) Fetch(req require.Requirement, query string, args ...interface{}) ([]*Issue, error)

Fetch fetches a list of Issue based on a supplied query. This is mostly used for join queries that map its result columns to the fields of Issue. Other queries might be better handled by GetXxx or Select methods.

func (IssueTable) GetIssueById added in v0.16.0

func (tbl IssueTable) GetIssueById(req require.Requirement, id int64) (*Issue, error)

GetIssueById gets the record with a given primary key value. If not found, *Issue will be nil.

func (IssueTable) GetIssuesByAssignee added in v0.16.0

func (tbl IssueTable) GetIssuesByAssignee(req require.Requirement, assignee string) ([]*Issue, error)

GetIssuesByAssignee gets the records with a given assignee value. If not found, the resulting slice will be empty (nil).

func (IssueTable) GetIssuesById added in v0.16.0

func (tbl IssueTable) GetIssuesById(req require.Requirement, id ...int64) (list []*Issue, err error)

GetIssuesById 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 (IssueTable) Insert

func (tbl IssueTable) Insert(req require.Requirement, vv ...*Issue) error

Insert adds new records for the Issues.// The Issues have their primary key fields set to the new record identifiers. The Issue.PreInsert() method will be called, if it exists.

func (IssueTable) IsTx

func (tbl IssueTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (IssueTable) Logger

func (tbl IssueTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (IssueTable) Name

func (tbl IssueTable) Name() sqlapi.TableName

Name gets the table name.

func (IssueTable) PkColumn added in v0.25.0

func (tbl IssueTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (IssueTable) Query

func (tbl IssueTable) Query(req require.Requirement, query string, args ...interface{}) ([]*Issue, error)

Query is the low-level request method for this table. The SQL query must return all the columns necessary for Issue 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 *sqlapi.Rows if you need to access its data as a map.

func (IssueTable) QueryOneNullFloat64 added in v0.9.0

func (tbl IssueTable) 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 (IssueTable) QueryOneNullInt64 added in v0.9.0

func (tbl IssueTable) 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 (IssueTable) QueryOneNullString added in v0.9.0

func (tbl IssueTable) 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 (IssueTable) Select

Select allows Issues 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 (IssueTable) SelectOne

SelectOne allows a single Issue to be obtained from the table that matches 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. 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 (IssueTable) SelectOneWhere added in v0.9.0

func (tbl IssueTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Issue, error)

SelectOneWhere allows a single Issue to be obtained from the table that matches 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 (IssueTable) SelectWhere added in v0.9.0

func (tbl IssueTable) SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Issue, error)

SelectWhere allows Issues 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 (IssueTable) SliceAssignee

func (tbl IssueTable) SliceAssignee(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceAssignee gets the assignee 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 (IssueTable) SliceBigbody added in v0.8.0

func (tbl IssueTable) SliceBigbody(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceBigbody gets the bigbody 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 (IssueTable) SliceId

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 (IssueTable) SliceNumber

func (tbl IssueTable) SliceNumber(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int, error)

SliceNumber gets the number 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 (IssueTable) SliceState

func (tbl IssueTable) SliceState(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceState gets the state 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 (IssueTable) SliceTitle

func (tbl IssueTable) SliceTitle(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

SliceTitle gets the title 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 (IssueTable) Transact added in v0.51.0

func (tbl IssueTable) Transact(txOptions *sql.TxOptions, fn func(IssueTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (IssueTable) Truncate

func (tbl IssueTable) 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 (IssueTable) Tx

func (tbl IssueTable) Tx() sqlapi.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 (IssueTable) Update

func (tbl IssueTable) Update(req require.Requirement, vv ...*Issue) (int64, error)

Update updates records, matching them by primary key. It returns the number of rows affected. The Issue.PreUpdate(Execer) method will be called, if it exists.

func (IssueTable) UpdateFields

func (tbl IssueTable) 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 (IssueTable) Upsert added in v0.49.0

func (tbl IssueTable) Upsert(v *Issue, 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 (IssueTable) Using added in v0.9.0

func (tbl IssueTable) Using(tx sqlapi.SqlTx) IssueTabler

Using returns a modified IssueTabler 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 (IssueTable) WithConstraint added in v0.12.0

func (tbl IssueTable) WithConstraint(cc ...constraint.Constraint) IssueTabler

WithConstraint returns a modified IssueTabler with added data consistency constraints.

func (IssueTable) WithContext

func (tbl IssueTable) WithContext(ctx context.Context) IssueTabler

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 (IssueTable) WithPrefix

func (tbl IssueTable) WithPrefix(pfx string) IssueTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type IssueTabler added in v0.53.0

type IssueTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified IssueTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) IssueTabler

	// WithPrefix returns a modified IssueTabler with a given table name prefix.
	WithPrefix(pfx string) IssueTabler

	// WithContext returns a modified IssueTabler with a given context.
	WithContext(ctx context.Context) IssueTabler

	// Using returns a modified IssueTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) IssueTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(IssueTabler) error) error

	// CreateTable creates the table.
	CreateTable(ifNotExists bool) (int64, error)

	// DropTable drops the table, destroying all its data.
	DropTable(ifExists bool) (int64, error)

	// CreateTableWithIndexes invokes CreateTable then CreateIndexes.
	CreateTableWithIndexes(ifNotExist bool) (err error)

	// CreateIndexes executes queries that create the indexes needed by the Issue table.
	CreateIndexes(ifNotExist bool) (err error)

	// CreateIssueAssigneeIndex creates the issue_assignee index.
	CreateIssueAssigneeIndex(ifNotExist bool) error

	// DropIssueAssigneeIndex drops the issue_assignee index.
	DropIssueAssigneeIndex(ifExists bool) error

	// Truncate drops every record from the table, if possible.
	Truncate(force bool) (err error)

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for Issue values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*Issue, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

	// GetIssuesById gets records from the table according to a list of primary keys.
	GetIssuesById(req require.Requirement, id ...int64) (list []*Issue, err error)

	// GetIssueById gets the record with a given primary key value.
	GetIssueById(req require.Requirement, id int64) (*Issue, error)

	// GetIssuesByAssignee gets the records with a given assignee value.
	GetIssuesByAssignee(req require.Requirement, assignee string) ([]*Issue, error)

	// SelectOneWhere allows a single Issue to be obtained from the table that matches a 'where' clause.
	SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*Issue, error)

	// SelectOne allows a single Issue to be obtained from the table that matches a 'where' clause.
	SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*Issue, error)

	// SelectWhere allows Issues to be obtained from the table that match a 'where' clause.
	SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*Issue, error)

	// Select allows Issues to be obtained from the table that match a 'where' clause.
	Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*Issue, error)

	// CountWhere counts Issues in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Issues in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)

	// SliceId gets the id column for all rows that match the 'where' condition.
	SliceId(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceNumber gets the number column for all rows that match the 'where' condition.
	SliceNumber(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int, error)

	// SliceTitle gets the title column for all rows that match the 'where' condition.
	SliceTitle(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceBigbody gets the bigbody column for all rows that match the 'where' condition.
	SliceBigbody(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceAssignee gets the assignee column for all rows that match the 'where' condition.
	SliceAssignee(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceState gets the state column for all rows that match the 'where' condition.
	SliceState(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// Insert adds new records for the Issues, setting the primary key field for each one.
	Insert(req require.Requirement, vv ...*Issue) error

	// Update updates records, matching them by primary key.
	Update(req require.Requirement, vv ...*Issue) (int64, error)
}

IssueTabler lists methods provided by IssueTable.

type LUserTable added in v0.53.0

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

LUserTable 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 CopyTableAsLUserTable added in v0.53.0

func CopyTableAsLUserTable(origin sqlapi.Table) LUserTable

CopyTableAsLUserTable 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 NewLUserTable added in v0.53.0

func NewLUserTable(name string, d sqlapi.Database) LUserTable

NewLUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (LUserTable) Constraints added in v0.53.0

func (tbl LUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (LUserTable) Ctx added in v0.53.0

func (tbl LUserTable) Ctx() context.Context

Ctx gets the current request context.

func (LUserTable) DB added in v0.53.0

func (tbl LUserTable) DB() sqlapi.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 (LUserTable) Database added in v0.53.0

func (tbl LUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (LUserTable) Dialect added in v0.53.0

func (tbl LUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (LUserTable) Execer added in v0.53.0

func (tbl LUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (LUserTable) IsTx added in v0.53.0

func (tbl LUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (LUserTable) Logger added in v0.53.0

func (tbl LUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (LUserTable) Name added in v0.53.0

func (tbl LUserTable) Name() sqlapi.TableName

Name gets the table name.

func (LUserTable) PkColumn added in v0.53.0

func (tbl LUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (LUserTable) SliceAddressid added in v0.53.0

func (tbl LUserTable) 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 (LUserTable) SliceAvatar added in v0.53.0

func (tbl LUserTable) 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 (LUserTable) SliceEmailaddress added in v0.53.0

func (tbl LUserTable) 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 (LUserTable) SliceF32 added in v0.53.0

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 (LUserTable) SliceF64 added in v0.53.0

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 (LUserTable) SliceI16 added in v0.53.0

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 (LUserTable) SliceI32 added in v0.53.0

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 (LUserTable) SliceI64 added in v0.53.0

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 (LUserTable) SliceI8 added in v0.53.0

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 (LUserTable) SliceLastupdated added in v0.53.0

func (tbl LUserTable) 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 (LUserTable) SliceName added in v0.53.0

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 (LUserTable) SliceRole added in v0.53.0

func (tbl LUserTable) 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 (LUserTable) SliceU16 added in v0.53.0

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 (LUserTable) SliceU32 added in v0.53.0

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 (LUserTable) SliceU64 added in v0.53.0

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 (LUserTable) SliceU8 added in v0.53.0

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 (LUserTable) SliceUid added in v0.53.0

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 (LUserTable) Transact added in v0.53.0

func (tbl LUserTable) Transact(txOptions *sql.TxOptions, fn func(LUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (LUserTable) Tx added in v0.53.0

func (tbl LUserTable) Tx() sqlapi.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 (LUserTable) Using added in v0.53.0

func (tbl LUserTable) Using(tx sqlapi.SqlTx) LUserTabler

Using returns a modified LUserTabler 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 (LUserTable) WithConstraint added in v0.53.0

func (tbl LUserTable) WithConstraint(cc ...constraint.Constraint) LUserTabler

WithConstraint returns a modified LUserTabler with added data consistency constraints.

func (LUserTable) WithContext added in v0.53.0

func (tbl LUserTable) WithContext(ctx context.Context) LUserTabler

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 (LUserTable) WithPrefix added in v0.53.0

func (tbl LUserTable) WithPrefix(pfx string) LUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type LUserTabler added in v0.53.0

type LUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified LUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) LUserTabler

	// WithPrefix returns a modified LUserTabler with a given table name prefix.
	WithPrefix(pfx string) LUserTabler

	// WithContext returns a modified LUserTabler with a given context.
	WithContext(ctx context.Context) LUserTabler

	// Using returns a modified LUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) LUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(LUserTabler) error) error

	// SliceUid gets the uid column for all rows that match the 'where' condition.
	SliceUid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceName gets the name column for all rows that match the 'where' condition.
	SliceName(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceEmailaddress gets the emailaddress column for all rows that match the 'where' condition.
	SliceEmailaddress(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceAddressid gets the addressid column for all rows that match the 'where' condition.
	SliceAddressid(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceAvatar gets the avatar column for all rows that match the 'where' condition.
	SliceAvatar(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]string, error)

	// SliceLastupdated gets the lastupdated column for all rows that match the 'where' condition.
	SliceLastupdated(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceI8 gets the i8 column for all rows that match the 'where' condition.
	SliceI8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int8, error)

	// SliceU8 gets the u8 column for all rows that match the 'where' condition.
	SliceU8(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint8, error)

	// SliceI16 gets the i16 column for all rows that match the 'where' condition.
	SliceI16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int16, error)

	// SliceU16 gets the u16 column for all rows that match the 'where' condition.
	SliceU16(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint16, error)

	// SliceI32 gets the i32 column for all rows that match the 'where' condition.
	SliceI32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int32, error)

	// SliceU32 gets the u32 column for all rows that match the 'where' condition.
	SliceU32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint32, error)

	// SliceI64 gets the i64 column for all rows that match the 'where' condition.
	SliceI64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

	// SliceU64 gets the u64 column for all rows that match the 'where' condition.
	SliceU64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]uint64, error)

	// SliceRole gets the role column for all rows that match the 'where' condition.
	SliceRole(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Role, error)

	// SliceF32 gets the f32 column for all rows that match the 'where' condition.
	SliceF32(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float32, error)

	// SliceF64 gets the f64 column for all rows that match the 'where' condition.
	SliceF64(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]float64, error)
}

LUserTabler lists methods provided by LUserTable.

type Numbers added in v0.19.0

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 PUserTable added in v0.53.0

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

PUserTable 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 CopyTableAsPUserTable added in v0.53.0

func CopyTableAsPUserTable(origin sqlapi.Table) PUserTable

CopyTableAsPUserTable 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 NewPUserTable added in v0.53.0

func NewPUserTable(name string, d sqlapi.Database) PUserTable

NewPUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (PUserTable) Constraints added in v0.53.0

func (tbl PUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (PUserTable) Ctx added in v0.53.0

func (tbl PUserTable) Ctx() context.Context

Ctx gets the current request context.

func (PUserTable) DB added in v0.53.0

func (tbl PUserTable) DB() sqlapi.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 (PUserTable) Database added in v0.53.0

func (tbl PUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (PUserTable) Dialect added in v0.53.0

func (tbl PUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (PUserTable) Exec added in v0.53.0

func (tbl PUserTable) 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 (PUserTable) Execer added in v0.53.0

func (tbl PUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (PUserTable) Insert added in v0.53.0

func (tbl PUserTable) 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 (PUserTable) IsTx added in v0.53.0

func (tbl PUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (PUserTable) Logger added in v0.53.0

func (tbl PUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (PUserTable) Name added in v0.53.0

func (tbl PUserTable) Name() sqlapi.TableName

Name gets the table name.

func (PUserTable) PkColumn added in v0.53.0

func (tbl PUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (PUserTable) Transact added in v0.53.0

func (tbl PUserTable) Transact(txOptions *sql.TxOptions, fn func(PUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (PUserTable) Tx added in v0.53.0

func (tbl PUserTable) Tx() sqlapi.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 (PUserTable) Update added in v0.53.0

func (tbl PUserTable) 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 (PUserTable) UpdateFields added in v0.53.0

func (tbl PUserTable) 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 (PUserTable) Upsert added in v0.53.0

func (tbl PUserTable) 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 (PUserTable) Using added in v0.53.0

func (tbl PUserTable) Using(tx sqlapi.SqlTx) PUserTabler

Using returns a modified PUserTabler 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 (PUserTable) WithConstraint added in v0.53.0

func (tbl PUserTable) WithConstraint(cc ...constraint.Constraint) PUserTabler

WithConstraint returns a modified PUserTabler with added data consistency constraints.

func (PUserTable) WithContext added in v0.53.0

func (tbl PUserTable) WithContext(ctx context.Context) PUserTabler

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 (PUserTable) WithPrefix added in v0.53.0

func (tbl PUserTable) WithPrefix(pfx string) PUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type PUserTabler added in v0.53.0

type PUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified PUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) PUserTabler

	// WithPrefix returns a modified PUserTabler with a given table name prefix.
	WithPrefix(pfx string) PUserTabler

	// WithContext returns a modified PUserTabler with a given context.
	WithContext(ctx context.Context) PUserTabler

	// Using returns a modified PUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) PUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(PUserTabler) error) error

	// Insert adds new records for the Users, setting the primary key field for each one.
	Insert(req require.Requirement, vv ...*User) error

	// Update updates records, matching them by primary key.
	Update(req require.Requirement, vv ...*User) (int64, error)
}

PUserTabler lists methods provided by PUserTable.

type QUserTable added in v0.53.0

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

QUserTable 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 CopyTableAsQUserTable added in v0.53.0

func CopyTableAsQUserTable(origin sqlapi.Table) QUserTable

CopyTableAsQUserTable 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 NewQUserTable added in v0.53.0

func NewQUserTable(name string, d sqlapi.Database) QUserTable

NewQUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (QUserTable) Constraints added in v0.53.0

func (tbl QUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (QUserTable) Ctx added in v0.53.0

func (tbl QUserTable) Ctx() context.Context

Ctx gets the current request context.

func (QUserTable) DB added in v0.53.0

func (tbl QUserTable) DB() sqlapi.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 (QUserTable) Database added in v0.53.0

func (tbl QUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (QUserTable) Dialect added in v0.53.0

func (tbl QUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (QUserTable) Execer added in v0.53.0

func (tbl QUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (QUserTable) IsTx added in v0.53.0

func (tbl QUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (QUserTable) Logger added in v0.53.0

func (tbl QUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (QUserTable) Name added in v0.53.0

func (tbl QUserTable) Name() sqlapi.TableName

Name gets the table name.

func (QUserTable) PkColumn added in v0.53.0

func (tbl QUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (QUserTable) Query added in v0.53.0

func (tbl QUserTable) 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 *sqlapi.Rows if you need to access its data as a map.

func (QUserTable) QueryOneNullFloat64 added in v0.53.0

func (tbl QUserTable) 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 (QUserTable) QueryOneNullInt64 added in v0.53.0

func (tbl QUserTable) 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 (QUserTable) QueryOneNullString added in v0.53.0

func (tbl QUserTable) 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 (QUserTable) Transact added in v0.53.0

func (tbl QUserTable) Transact(txOptions *sql.TxOptions, fn func(QUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (QUserTable) Tx added in v0.53.0

func (tbl QUserTable) Tx() sqlapi.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 (QUserTable) Using added in v0.53.0

func (tbl QUserTable) Using(tx sqlapi.SqlTx) QUserTabler

Using returns a modified QUserTabler 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 (QUserTable) WithConstraint added in v0.53.0

func (tbl QUserTable) WithConstraint(cc ...constraint.Constraint) QUserTabler

WithConstraint returns a modified QUserTabler with added data consistency constraints.

func (QUserTable) WithContext added in v0.53.0

func (tbl QUserTable) WithContext(ctx context.Context) QUserTabler

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 (QUserTable) WithPrefix added in v0.53.0

func (tbl QUserTable) WithPrefix(pfx string) QUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type QUserTabler added in v0.53.0

type QUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified QUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) QUserTabler

	// WithPrefix returns a modified QUserTabler with a given table name prefix.
	WithPrefix(pfx string) QUserTabler

	// WithContext returns a modified QUserTabler with a given context.
	WithContext(ctx context.Context) QUserTabler

	// Using returns a modified QUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) QUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(QUserTabler) error) error

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for User values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*User, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)
}

QUserTabler lists methods provided by QUserTable.

type QualName added in v0.33.0

type QualName string

type Role added in v0.10.0

type Role int8
const (
	Unknown Role = iota
	UserRole
	AdminRole
)

func (*Role) Parse added in v0.10.0

func (v *Role) Parse(s string) error

func (*Role) Scan added in v0.10.0

func (r *Role) Scan(value interface{}) error

func (Role) String added in v0.10.0

func (v Role) String() string

func (Role) Value added in v0.10.0

func (r Role) Value() (driver.Value, error)

type SUserTable added in v0.8.0

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

SUserTable 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 CopyTableAsSUserTable added in v0.8.0

func CopyTableAsSUserTable(origin sqlapi.Table) SUserTable

CopyTableAsSUserTable 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 NewSUserTable added in v0.8.0

func NewSUserTable(name string, d sqlapi.Database) SUserTable

NewSUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (SUserTable) Constraints added in v0.14.0

func (tbl SUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (SUserTable) Count added in v0.53.0

func (tbl SUserTable) 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 (SUserTable) CountWhere added in v0.53.0

func (tbl SUserTable) 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 (SUserTable) Ctx added in v0.8.0

func (tbl SUserTable) Ctx() context.Context

Ctx gets the current request context.

func (SUserTable) DB added in v0.8.0

func (tbl SUserTable) DB() sqlapi.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 (SUserTable) Database added in v0.12.0

func (tbl SUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (SUserTable) Dialect added in v0.8.0

func (tbl SUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (SUserTable) Execer added in v0.12.0

func (tbl SUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (SUserTable) Fetch added in v0.53.0

func (tbl SUserTable) 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 (SUserTable) GetUserByEmailAddress added in v0.53.0

func (tbl SUserTable) 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 (SUserTable) GetUserByName added in v0.53.0

func (tbl SUserTable) 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 (SUserTable) GetUserByUid added in v0.53.0

func (tbl SUserTable) 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 (SUserTable) GetUsersByUid added in v0.53.0

func (tbl SUserTable) 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 (SUserTable) IsTx added in v0.8.0

func (tbl SUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (SUserTable) Logger added in v0.8.0

func (tbl SUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (SUserTable) Name added in v0.8.0

func (tbl SUserTable) Name() sqlapi.TableName

Name gets the table name.

func (SUserTable) PkColumn added in v0.25.0

func (tbl SUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (SUserTable) Query added in v0.8.0

func (tbl SUserTable) 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 *sqlapi.Rows if you need to access its data as a map.

func (SUserTable) QueryOneNullFloat64 added in v0.9.0

func (tbl SUserTable) 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 (SUserTable) QueryOneNullInt64 added in v0.9.0

func (tbl SUserTable) 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 (SUserTable) QueryOneNullString added in v0.9.0

func (tbl SUserTable) 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 (SUserTable) Select added in v0.53.0

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 (SUserTable) SelectOne added in v0.53.0

func (tbl SUserTable) SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*User, error)

SelectOne allows a single User to be obtained from the table that matches 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. 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 (SUserTable) SelectOneWhere added in v0.53.0

func (tbl SUserTable) SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*User, error)

SelectOneWhere allows a single User to be obtained from the table that matches 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 (SUserTable) SelectWhere added in v0.53.0

func (tbl SUserTable) 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 (SUserTable) Transact added in v0.51.0

func (tbl SUserTable) Transact(txOptions *sql.TxOptions, fn func(SUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (SUserTable) Tx added in v0.8.0

func (tbl SUserTable) Tx() sqlapi.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 (SUserTable) Using added in v0.9.0

func (tbl SUserTable) Using(tx sqlapi.SqlTx) SUserTabler

Using returns a modified SUserTabler 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 (SUserTable) WithConstraint added in v0.12.0

func (tbl SUserTable) WithConstraint(cc ...constraint.Constraint) SUserTabler

WithConstraint returns a modified SUserTabler with added data consistency constraints.

func (SUserTable) WithContext added in v0.8.0

func (tbl SUserTable) WithContext(ctx context.Context) SUserTabler

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 (SUserTable) WithPrefix added in v0.8.0

func (tbl SUserTable) WithPrefix(pfx string) SUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type SUserTabler added in v0.53.0

type SUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified SUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) SUserTabler

	// WithPrefix returns a modified SUserTabler with a given table name prefix.
	WithPrefix(pfx string) SUserTabler

	// WithContext returns a modified SUserTabler with a given context.
	WithContext(ctx context.Context) SUserTabler

	// Using returns a modified SUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) SUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(SUserTabler) error) error

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for User values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*User, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

	// GetUsersByUid gets records from the table according to a list of primary keys.
	GetUsersByUid(req require.Requirement, id ...int64) (list []*User, err error)

	// GetUserByUid gets the record with a given primary key value.
	GetUserByUid(req require.Requirement, id int64) (*User, error)

	// GetUserByEmailAddress gets the record with a given emailaddress value.
	GetUserByEmailAddress(req require.Requirement, emailaddress string) (*User, error)

	// GetUserByName gets the record with a given name value.
	GetUserByName(req require.Requirement, name string) (*User, error)

	// SelectOneWhere allows a single User to be obtained from the table that matches a 'where' clause.
	SelectOneWhere(req require.Requirement, where, orderBy string, args ...interface{}) (*User, error)

	// SelectOne allows a single User to be obtained from the table that matches a 'where' clause.
	SelectOne(req require.Requirement, wh where.Expression, qc where.QueryConstraint) (*User, error)

	// SelectWhere allows Users to be obtained from the table that match a 'where' clause.
	SelectWhere(req require.Requirement, where, orderBy string, args ...interface{}) ([]*User, error)

	// Select allows Users to be obtained from the table that match a 'where' clause.
	Select(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]*User, error)

	// CountWhere counts Users in the table that match a 'where' clause.
	CountWhere(where string, args ...interface{}) (count int64, err error)

	// Count counts the Users in the table that match a 'where' clause.
	Count(wh where.Expression) (count int64, err error)
}

SUserTabler lists methods provided by SUserTable.

type UUserTable added in v0.8.0

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

UUserTable 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 CopyTableAsUUserTable added in v0.8.0

func CopyTableAsUUserTable(origin sqlapi.Table) UUserTable

CopyTableAsUUserTable 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 NewUUserTable added in v0.8.0

func NewUUserTable(name string, d sqlapi.Database) UUserTable

NewUUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (UUserTable) Constraints added in v0.14.0

func (tbl UUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (UUserTable) Ctx added in v0.8.0

func (tbl UUserTable) Ctx() context.Context

Ctx gets the current request context.

func (UUserTable) DB added in v0.8.0

func (tbl UUserTable) DB() sqlapi.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 (UUserTable) Database added in v0.12.0

func (tbl UUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (UUserTable) Dialect added in v0.8.0

func (tbl UUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (UUserTable) Exec added in v0.8.0

func (tbl UUserTable) 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 (UUserTable) Execer added in v0.12.0

func (tbl UUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (UUserTable) IsTx added in v0.8.0

func (tbl UUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (UUserTable) Logger added in v0.8.0

func (tbl UUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (UUserTable) Name added in v0.8.0

func (tbl UUserTable) Name() sqlapi.TableName

Name gets the table name.

func (UUserTable) PkColumn added in v0.25.0

func (tbl UUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (UUserTable) Transact added in v0.51.0

func (tbl UUserTable) Transact(txOptions *sql.TxOptions, fn func(UUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (UUserTable) Tx added in v0.8.0

func (tbl UUserTable) Tx() sqlapi.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 (UUserTable) Update added in v0.8.0

func (tbl UUserTable) 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 (UUserTable) UpdateFields added in v0.8.0

func (tbl UUserTable) 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 (UUserTable) Using added in v0.9.0

func (tbl UUserTable) Using(tx sqlapi.SqlTx) UUserTabler

Using returns a modified UUserTabler 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 (UUserTable) WithConstraint added in v0.12.0

func (tbl UUserTable) WithConstraint(cc ...constraint.Constraint) UUserTabler

WithConstraint returns a modified UUserTabler with added data consistency constraints.

func (UUserTable) WithContext added in v0.8.0

func (tbl UUserTable) WithContext(ctx context.Context) UUserTabler

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 (UUserTable) WithPrefix added in v0.8.0

func (tbl UUserTable) WithPrefix(pfx string) UUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type UUserTabler added in v0.53.0

type UUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified UUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) UUserTabler

	// WithPrefix returns a modified UUserTabler with a given table name prefix.
	WithPrefix(pfx string) UUserTabler

	// WithContext returns a modified UUserTabler with a given context.
	WithContext(ctx context.Context) UUserTabler

	// Using returns a modified UUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) UUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(UUserTabler) error) error

	// Update updates records, matching them by primary key.
	Update(req require.Requirement, vv ...*User) (int64, error)
}

UUserTabler lists methods provided by UUserTable.

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 ScanAUsers added in v0.50.0

func ScanAUsers(query string, rows sqlapi.SqlRows, firstOnly bool) (vv []*User, n int64, err error)

ScanAUsers 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 ScanDbUsers added in v0.50.0

func ScanDbUsers(query string, rows sqlapi.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) PostGet added in v0.8.0

func (u *User) PostGet() error

func (*User) PreInsert

func (u *User) PreInsert() error

These hooks are just used here for testing, but you could put whatever you like in them.

func (*User) PreUpdate

func (u *User) PreUpdate() error

func (*User) SetActive added in v0.8.0

func (v *User) SetActive(x bool) *User

SetActive sets the Active field and returns the modified User.

func (*User) SetAddressId added in v0.12.0

func (v *User) SetAddressId(x int64) *User

SetAddressId sets the AddressId field and returns the modified User.

func (*User) SetAdmin added in v0.8.0

func (v *User) SetAdmin(x bool) *User

SetAdmin sets the Admin field and returns the modified User.

func (*User) SetAvatar added in v0.8.0

func (v *User) SetAvatar(x string) *User

SetAvatar sets the Avatar field and returns the modified User.

func (*User) SetEmailAddress added in v0.8.0

func (v *User) SetEmailAddress(x string) *User

SetEmailAddress sets the EmailAddress field and returns the modified User.

func (*User) SetF32 added in v0.19.0

func (v *User) SetF32(x float32) *User

SetF32 sets the F32 field and returns the modified User.

func (*User) SetF64 added in v0.19.0

func (v *User) SetF64(x float64) *User

SetF64 sets the F64 field and returns the modified User.

func (*User) SetFave added in v0.8.0

func (v *User) SetFave(x big.Int) *User

SetFave sets the Fave field and returns the modified User.

func (*User) SetI16 added in v0.19.0

func (v *User) SetI16(x int16) *User

SetI16 sets the I16 field and returns the modified User.

func (*User) SetI32 added in v0.19.0

func (v *User) SetI32(x int32) *User

SetI32 sets the I32 field and returns the modified User.

func (*User) SetI64 added in v0.19.0

func (v *User) SetI64(x int64) *User

SetI64 sets the I64 field and returns the modified User.

func (*User) SetI8 added in v0.19.0

func (v *User) SetI8(x int8) *User

SetI8 sets the I8 field and returns the modified User.

func (*User) SetLastUpdated added in v0.8.0

func (v *User) SetLastUpdated(x int64) *User

SetLastUpdated sets the LastUpdated field and returns the modified User.

func (*User) SetName added in v0.16.0

func (v *User) SetName(x string) *User

SetName sets the Name field and returns the modified User.

func (*User) SetRole added in v0.10.0

func (v *User) SetRole(x Role) *User

SetRole sets the Role field and returns the modified User.

func (*User) SetU16 added in v0.19.0

func (v *User) SetU16(x uint16) *User

SetU16 sets the U16 field and returns the modified User.

func (*User) SetU32 added in v0.19.0

func (v *User) SetU32(x uint32) *User

SetU32 sets the U32 field and returns the modified User.

func (*User) SetU64 added in v0.19.0

func (v *User) SetU64(x uint64) *User

SetU64 sets the U64 field and returns the modified User.

func (*User) SetU8 added in v0.19.0

func (v *User) SetU8(x uint8) *User

SetU8 sets the U8 field and returns the modified User.

func (*User) SetUid added in v0.8.0

func (v *User) SetUid(x int64) *User

SetUid sets the Uid field and returns the modified User.

func (*User) Setsecret added in v0.8.0

func (v *User) Setsecret(x string) *User

Setsecret sets the secret field and returns the modified User.

func (*User) Settoken added in v0.8.0

func (v *User) Settoken(x string) *User

Settoken sets the token field and returns the modified User.

type UserAddress added in v0.53.0

type UserAddress struct {
	Uid          int64  `sql:"pk: true, auto: true"`
	Name         string `sql:"unique: user_login"`
	EmailAddress string `sql:"nk: true"`
	Address      *AddressFields
	Avatar       *string
	Role         *Role `sql:"type: text, size: 20"`
	Active       bool
	Admin        bool
	Fave         *big.Int `sql:"encode: json"`
	LastUpdated  int64
}

type UserAddressJoin added in v0.53.0

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

UserAddressJoin 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 CopyTableAsUserAddressJoin added in v0.53.0

func CopyTableAsUserAddressJoin(origin sqlapi.Table) UserAddressJoin

CopyTableAsUserAddressJoin copies a table instance, retaining the name etc but providing methods appropriate for 'UserAddress'. It doesn't copy the constraints of the original table.

It serves to provide methods appropriate for 'UserAddress'. 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 NewUserAddressJoin added in v0.53.0

func NewUserAddressJoin(name string, d sqlapi.Database) UserAddressJoin

NewUserAddressJoin returns a new table instance. If a blank table name is supplied, the default name "useraddresses" will be used instead. The request context is initialised with the background.

func (UserAddressJoin) Constraints added in v0.53.0

func (tbl UserAddressJoin) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (UserAddressJoin) Ctx added in v0.53.0

func (tbl UserAddressJoin) Ctx() context.Context

Ctx gets the current request context.

func (UserAddressJoin) DB added in v0.53.0

func (tbl UserAddressJoin) DB() sqlapi.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 (UserAddressJoin) Database added in v0.53.0

func (tbl UserAddressJoin) Database() sqlapi.Database

Database gets the shared database information.

func (UserAddressJoin) Dialect added in v0.53.0

func (tbl UserAddressJoin) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (UserAddressJoin) Execer added in v0.53.0

func (tbl UserAddressJoin) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (UserAddressJoin) IsTx added in v0.53.0

func (tbl UserAddressJoin) IsTx() bool

IsTx tests whether this is within a transaction.

func (UserAddressJoin) Logger added in v0.53.0

func (tbl UserAddressJoin) Logger() sqlapi.Logger

Logger gets the trace logger.

func (UserAddressJoin) Name added in v0.53.0

func (tbl UserAddressJoin) Name() sqlapi.TableName

Name gets the table name.

func (UserAddressJoin) PkColumn added in v0.53.0

func (tbl UserAddressJoin) PkColumn() string

PkColumn gets the column name used as a primary key.

func (UserAddressJoin) Query added in v0.53.0

func (tbl UserAddressJoin) Query(req require.Requirement, query string, args ...interface{}) ([]*UserAddress, error)

Query is the low-level request method for this table. The SQL query must return all the columns necessary for UserAddress 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 *sqlapi.Rows if you need to access its data as a map.

func (UserAddressJoin) QueryOneNullFloat64 added in v0.53.0

func (tbl UserAddressJoin) 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 (UserAddressJoin) QueryOneNullInt64 added in v0.53.0

func (tbl UserAddressJoin) 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 (UserAddressJoin) QueryOneNullString added in v0.53.0

func (tbl UserAddressJoin) 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 (UserAddressJoin) Transact added in v0.53.0

func (tbl UserAddressJoin) Transact(txOptions *sql.TxOptions, fn func(UserAddressJoiner) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (UserAddressJoin) Tx added in v0.53.0

func (tbl UserAddressJoin) Tx() sqlapi.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 (UserAddressJoin) Using added in v0.53.0

Using returns a modified UserAddressJoiner 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 (UserAddressJoin) WithConstraint added in v0.53.0

func (tbl UserAddressJoin) WithConstraint(cc ...constraint.Constraint) UserAddressJoiner

WithConstraint returns a modified UserAddressJoiner with added data consistency constraints.

func (UserAddressJoin) WithContext added in v0.53.0

func (tbl UserAddressJoin) WithContext(ctx context.Context) UserAddressJoiner

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 (UserAddressJoin) WithPrefix added in v0.53.0

func (tbl UserAddressJoin) WithPrefix(pfx string) UserAddressJoiner

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type UserAddressJoiner added in v0.53.0

type UserAddressJoiner interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified UserAddressJoiner with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) UserAddressJoiner

	// WithPrefix returns a modified UserAddressJoiner with a given table name prefix.
	WithPrefix(pfx string) UserAddressJoiner

	// WithContext returns a modified UserAddressJoiner with a given context.
	WithContext(ctx context.Context) UserAddressJoiner

	// Using returns a modified UserAddressJoiner using the transaction supplied.
	Using(tx sqlapi.SqlTx) UserAddressJoiner

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(UserAddressJoiner) error) error

	// Query is the low-level request method for this table using an SQL query that must return all the columns
	// necessary for UserAddress values.
	Query(req require.Requirement, query string, args ...interface{}) ([]*UserAddress, error)

	// QueryOneNullString is a low-level access method for one string, returning the first match.
	QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

	// QueryOneNullInt64 is a low-level access method for one int64, returning the first match.
	QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

	// QueryOneNullFloat64 is a low-level access method for one float64, returning the first match.
	QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)
}

UserAddressJoiner lists methods provided by UserAddressJoin.

type XUserTable added in v0.8.0

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

XUserTable 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 CopyTableAsXUserTable added in v0.8.0

func CopyTableAsXUserTable(origin sqlapi.Table) XUserTable

CopyTableAsXUserTable 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 NewXUserTable added in v0.8.0

func NewXUserTable(name string, d sqlapi.Database) XUserTable

NewXUserTable returns a new table instance. If a blank table name is supplied, the default name "users" will be used instead. The request context is initialised with the background.

func (XUserTable) Constraints added in v0.14.0

func (tbl XUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (XUserTable) Ctx added in v0.8.0

func (tbl XUserTable) Ctx() context.Context

Ctx gets the current request context.

func (XUserTable) DB added in v0.8.0

func (tbl XUserTable) DB() sqlapi.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 (XUserTable) Database added in v0.12.0

func (tbl XUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (XUserTable) Dialect added in v0.8.0

func (tbl XUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (XUserTable) Execer added in v0.12.0

func (tbl XUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (XUserTable) IsTx added in v0.8.0

func (tbl XUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (XUserTable) Logger added in v0.8.0

func (tbl XUserTable) Logger() sqlapi.Logger

Logger gets the trace logger.

func (XUserTable) Name added in v0.8.0

func (tbl XUserTable) Name() sqlapi.TableName

Name gets the table name.

func (XUserTable) PkColumn added in v0.25.0

func (tbl XUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (XUserTable) Transact added in v0.51.0

func (tbl XUserTable) Transact(txOptions *sql.TxOptions, fn func(XUserTabler) error) error

Transact runs the function provided within a transaction. If the function completes without error, the transaction is committed. If there is an error or a panic, the transaction is rolled back.

Nested transactions (i.e. within 'fn') are permitted: they execute within the outermost transaction. Therefore they do not commit until the outermost transaction commits.

func (XUserTable) Tx added in v0.8.0

func (tbl XUserTable) Tx() sqlapi.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 (XUserTable) Using added in v0.9.0

func (tbl XUserTable) Using(tx sqlapi.SqlTx) XUserTabler

Using returns a modified XUserTabler 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 (XUserTable) WithConstraint added in v0.12.0

func (tbl XUserTable) WithConstraint(cc ...constraint.Constraint) XUserTabler

WithConstraint returns a modified XUserTabler with added data consistency constraints.

func (XUserTable) WithContext added in v0.8.0

func (tbl XUserTable) WithContext(ctx context.Context) XUserTabler

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 (XUserTable) WithPrefix added in v0.8.0

func (tbl XUserTable) WithPrefix(pfx string) XUserTabler

WithPrefix sets the table name prefix for subsequent queries. The result is a modified copy of the table; the original is unchanged.

type XUserTabler added in v0.53.0

type XUserTabler interface {
	sqlapi.Table

	// Constraints returns the table's constraints.
	Constraints() constraint.Constraints

	// WithConstraint returns a modified XUserTabler with added data consistency constraints.
	WithConstraint(cc ...constraint.Constraint) XUserTabler

	// WithPrefix returns a modified XUserTabler with a given table name prefix.
	WithPrefix(pfx string) XUserTabler

	// WithContext returns a modified XUserTabler with a given context.
	WithContext(ctx context.Context) XUserTabler

	// Using returns a modified XUserTabler using the transaction supplied.
	Using(tx sqlapi.SqlTx) XUserTabler

	// Transact runs the function provided within a transaction.
	Transact(txOptions *sql.TxOptions, fn func(XUserTabler) error) error
}

XUserTabler lists methods provided by XUserTable.

Jump to

Keyboard shortcuts

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