demo

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: BSD-2-Clause Imports: 16 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 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 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 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 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 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 NumRUserTableColumns = 22

NumRUserTableColumns is the total number of columns in RUserTable.

View Source
const NumRUserTableDataColumns = 21

NumRUserTableDataColumns is the number of columns in RUserTable 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 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 RUserTableColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"

RUserTableColumnNames is the list of columns in RUserTable.

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

RUserTableDataColumnNames is the list of data columns in RUserTable.

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

func (tbl AUserTable) BeginTx(opts *sql.TxOptions) (AUserTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (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() *log.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(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

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 database. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

func (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 Example to be obtained from the table that match a 'where' clause and some limit. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

The args are for any placeholder parameters in the query.

func (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) SetPkColumn added in v0.25.0

func (tbl AUserTable) SetPkColumn(pk string) AUserTable

SetPkColumn sets the name of the primary key column. It defaults to "uid". The result is a modified copy of the table; the original is unchanged.

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

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

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (AUserTable) WithConstraint added in v0.12.0

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

WithConstraint returns a modified Table with added data consistency constraints.

func (AUserTable) WithContext added in v0.8.0

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

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

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

type Address added in v0.12.0

type Address struct {
	Id       int64    `sql:"pk: true, auto: true"`
	Lines    []string `sql:"encode: json"`
	Town     *string  `sql:"size: 80, index: townIdx"`
	Postcode string   `sql:"size: 20, index: postcodeIdx"`
}

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

func (tbl AddressTable) BeginTx(opts *sql.TxOptions) (AddressTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (AddressTable) Constraints 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() *log.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(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

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 database. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

func (AddressTable) SelectOneWhere added in v0.12.0

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

SelectOneWhere allows a single Example to be obtained from the table that match a 'where' clause and some limit. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

The args are for any placeholder parameters in the query.

func (AddressTable) SelectWhere 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) SetPkColumn added in v0.25.0

func (tbl AddressTable) SetPkColumn(pk string) AddressTable

SetPkColumn sets the name of the primary key column. It defaults to "id". The result is a modified copy of the table; the original is unchanged.

func (AddressTable) SliceId 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) 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) Using added in v0.12.0

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

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (AddressTable) WithConstraint added in v0.12.0

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

WithConstraint returns a modified Table with added data consistency constraints.

func (AddressTable) WithContext added in v0.12.0

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

WithContext sets the context for subsequent queries via this table. The result is a modified copy of the table; the original is unchanged.

The shared context in the *Database is not altered by this method. So it is possible to use different contexts for different (groups of) queries.

func (AddressTable) WithPrefix added in v0.12.0

func (tbl AddressTable) WithPrefix(pfx string) AddressTable

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

type Association

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

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

func (tbl AssociationTable) BeginTx(opts *sql.TxOptions) (AssociationTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (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() *log.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(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

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 database. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

func (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 Example to be obtained from the table that match a 'where' clause and some limit. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

The args are for any placeholder parameters in the query.

func (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) SetPkColumn added in v0.25.0

func (tbl AssociationTable) SetPkColumn(pk string) AssociationTable

SetPkColumn sets the name of the primary key column. It defaults to "id". The result is a modified copy of the table; the original is unchanged.

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

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (AssociationTable) WithConstraint added in v0.12.0

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

WithConstraint returns a modified Table with added data consistency constraints.

func (AssociationTable) WithContext

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

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

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

type Author

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

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

func (tbl CUserTable) BeginTx(opts *sql.TxOptions) (CUserTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (CUserTable) Constraints added in v0.14.0

func (tbl CUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

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

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

func (tbl CUserTable) Query(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

Wrap the result in *sqlapi.Rows if you need to access its data as a map.

func (CUserTable) QueryOneNullFloat64 added in v0.9.0

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

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

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

func (tbl CUserTable) SetPkColumn(pk string) CUserTable

SetPkColumn sets the name of the primary key column. It defaults to "uid". The result is a modified copy of the table; the original is unchanged.

func (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) CUserTable

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (CUserTable) WithConstraint added in v0.12.0

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

WithConstraint returns a modified Table with added data consistency constraints.

func (CUserTable) WithContext added in v0.8.0

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

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

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

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
}

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

func (tbl DUserTable) BeginTx(opts *sql.TxOptions) (DUserTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (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() *log.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) Query added in v0.8.0

func (tbl DUserTable) Query(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

Wrap the result in *sqlapi.Rows if you need to access its data as a map.

func (DUserTable) QueryOneNullFloat64 added in v0.9.0

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

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

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

func (tbl DUserTable) SetPkColumn(pk string) DUserTable

SetPkColumn sets the name of the primary key column. It defaults to "uid". The result is a modified copy of the table; the original is unchanged.

func (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) DUserTable

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (DUserTable) WithConstraint added in v0.12.0

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

WithConstraint returns a modified Table with added data consistency constraints.

func (DUserTable) WithContext added in v0.8.0

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

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

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

type Date

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

type Dates

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

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

func (tbl DbCompoundTable) BeginTx(opts *sql.TxOptions) (DbCompoundTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (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

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() *log.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(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

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 database. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

func (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 Example to be obtained from the table that match a 'where' clause and some limit. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

The args are for any placeholder parameters in the query.

func (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) 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 Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (DbCompoundTable) WithConstraint added in v0.12.0

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

WithConstraint returns a modified Table with added data consistency constraints.

func (DbCompoundTable) WithContext

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

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

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

type DbUserTable

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

DbUserTable holds a given table name with the database reference, providing access methods below. The Prefix field is often blank but can be used to hold a table name prefix (e.g. ending in '_'). Or it can specify the name of the schema, in which case it should have a trailing '.'.

func CopyTableAsDbUserTable 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) BeginTx

func (tbl DbUserTable) BeginTx(opts *sql.TxOptions) (DbUserTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (DbUserTable) Constraints 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() *log.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(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

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 database. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

func (DbUserTable) SelectOneWhere added in v0.9.0

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

SelectOneWhere allows a single Example to be obtained from the table that match a 'where' clause and some limit. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

The args are for any placeholder parameters in the query.

func (DbUserTable) SelectWhere 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) SetPkColumn added in v0.25.0

func (tbl DbUserTable) SetPkColumn(pk string) DbUserTable

SetPkColumn sets the name of the primary key column. It defaults to "uid". The result is a modified copy of the table; the original is unchanged.

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

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

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (DbUserTable) WithConstraint added in v0.12.0

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

WithConstraint returns a modified Table with added data consistency constraints.

func (DbUserTable) WithContext

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

WithContext sets the context for subsequent queries via this table. The result is a modified copy of the table; the original is unchanged.

The shared context in the *Database is not altered by this method. So it is possible to use different contexts for different (groups of) queries.

func (DbUserTable) WithPrefix

func (tbl DbUserTable) WithPrefix(pfx string) DbUserTable

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

type Email

type Email string

type Hook

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

type HookList

type HookList []*Hook

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 (*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) BeginTx

func (tbl IssueTable) BeginTx(opts *sql.TxOptions) (IssueTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (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() *log.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(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

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 database. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

func (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 Example to be obtained from the table that match a 'where' clause and some limit. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

The args are for any placeholder parameters in the query.

func (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) SetPkColumn added in v0.25.0

func (tbl IssueTable) SetPkColumn(pk string) IssueTable

SetPkColumn sets the name of the primary key column. It defaults to "id". The result is a modified copy of the table; the original is unchanged.

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

func (tbl IssueTable) Using(tx sqlapi.SqlTx) IssueTable

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (IssueTable) WithConstraint added in v0.12.0

func (tbl IssueTable) WithConstraint(cc ...constraint.Constraint) IssueTable

WithConstraint returns a modified Table with added data consistency constraints.

func (IssueTable) WithContext

func (tbl IssueTable) WithContext(ctx context.Context) IssueTable

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

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

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

type QualName string

type RUserTable added in v0.8.0

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

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

func CopyTableAsRUserTable(origin sqlapi.Table) RUserTable

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

func NewRUserTable(name string, d sqlapi.Database) RUserTable

NewRUserTable 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 (RUserTable) BeginTx added in v0.8.0

func (tbl RUserTable) BeginTx(opts *sql.TxOptions) (RUserTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (RUserTable) Constraints added in v0.14.0

func (tbl RUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (RUserTable) Count added in v0.8.0

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

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

func (tbl RUserTable) Ctx() context.Context

Ctx gets the current request context.

func (RUserTable) DB added in v0.8.0

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

func (tbl RUserTable) Database() sqlapi.Database

Database gets the shared database information.

func (RUserTable) Dialect added in v0.8.0

func (tbl RUserTable) Dialect() dialect.Dialect

Dialect gets the database dialect.

func (RUserTable) Execer added in v0.12.0

func (tbl RUserTable) Execer() sqlapi.Execer

Execer gets the wrapped database or transaction handle.

func (RUserTable) Fetch added in v0.17.0

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

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

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

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

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

func (tbl RUserTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (RUserTable) Logger added in v0.8.0

func (tbl RUserTable) Logger() *log.Logger

Logger gets the trace logger.

func (RUserTable) Name added in v0.8.0

func (tbl RUserTable) Name() sqlapi.TableName

Name gets the table name.

func (RUserTable) PkColumn added in v0.25.0

func (tbl RUserTable) PkColumn() string

PkColumn gets the column name used as a primary key.

func (RUserTable) Query added in v0.8.0

func (tbl RUserTable) Query(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

Wrap the result in *sqlapi.Rows if you need to access its data as a map.

func (RUserTable) QueryOneNullFloat64 added in v0.9.0

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

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

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

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

SelectOne allows a single User to be obtained from the database. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

func (RUserTable) SelectOneWhere added in v0.9.0

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

SelectOneWhere allows a single Example to be obtained from the table that match a 'where' clause and some limit. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed. If not found, *Example will be nil.

It places a requirement, which may be nil, on the size of the expected results: for example require.One controls whether an error is generated when no result is found.

The args are for any placeholder parameters in the query.

func (RUserTable) SelectWhere added in v0.9.0

func (tbl RUserTable) 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 (RUserTable) SetPkColumn added in v0.25.0

func (tbl RUserTable) SetPkColumn(pk string) RUserTable

SetPkColumn sets the name of the primary key column. It defaults to "uid". The result is a modified copy of the table; the original is unchanged.

func (RUserTable) Tx added in v0.8.0

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

func (tbl RUserTable) Using(tx sqlapi.SqlTx) RUserTable

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (RUserTable) WithConstraint added in v0.12.0

func (tbl RUserTable) WithConstraint(cc ...constraint.Constraint) RUserTable

WithConstraint returns a modified Table with added data consistency constraints.

func (RUserTable) WithContext added in v0.8.0

func (tbl RUserTable) WithContext(ctx context.Context) RUserTable

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

func (tbl RUserTable) WithPrefix(pfx string) RUserTable

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

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

func (tbl SUserTable) BeginTx(opts *sql.TxOptions) (SUserTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (SUserTable) Constraints added in v0.14.0

func (tbl SUserTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

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) 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() *log.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(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

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) SetPkColumn added in v0.25.0

func (tbl SUserTable) SetPkColumn(pk string) SUserTable

SetPkColumn sets the name of the primary key column. It defaults to "uid". The result is a modified copy of the table; the original is unchanged.

func (SUserTable) SliceAddressid added in v0.12.0

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

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

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

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

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (SUserTable) WithConstraint added in v0.12.0

func (tbl SUserTable) WithConstraint(cc ...constraint.Constraint) SUserTable

WithConstraint returns a modified Table with added data consistency constraints.

func (SUserTable) WithContext added in v0.8.0

func (tbl SUserTable) WithContext(ctx context.Context) SUserTable

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

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

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

func (tbl UUserTable) BeginTx(opts *sql.TxOptions) (UUserTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (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() *log.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) Query added in v0.8.0

func (tbl UUserTable) Query(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

Wrap the result in *sqlapi.Rows if you need to access its data as a map.

func (UUserTable) QueryOneNullFloat64 added in v0.9.0

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

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

func (tbl UUserTable) 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 (UUserTable) SetPkColumn added in v0.25.0

func (tbl UUserTable) SetPkColumn(pk string) UUserTable

SetPkColumn sets the name of the primary key column. It defaults to "uid". The result is a modified copy of the table; the original is unchanged.

func (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) UUserTable

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (UUserTable) WithConstraint added in v0.12.0

func (tbl UUserTable) WithConstraint(cc ...constraint.Constraint) UUserTable

WithConstraint returns a modified Table with added data consistency constraints.

func (UUserTable) WithContext added in v0.8.0

func (tbl UUserTable) WithContext(ctx context.Context) UUserTable

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

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

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 (*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 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) BeginTx added in v0.8.0

func (tbl XUserTable) BeginTx(opts *sql.TxOptions) (XUserTable, error)

BeginTx starts a transaction using the table's context. This context is used until the transaction is committed or rolled back.

If this context is cancelled, the sql package will roll back the transaction. In this case, Tx.Commit will then return an error.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

Panics if the Execer is not TxStarter.

func (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() *log.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) Query added in v0.8.0

func (tbl XUserTable) Query(query string, args ...interface{}) (sqlapi.SqlRows, error)

Query is the low-level request method for this table. 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 caller must call rows.Close() on the result.

Wrap the result in *sqlapi.Rows if you need to access its data as a map.

func (XUserTable) QueryOneNullFloat64 added in v0.9.0

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

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

func (tbl XUserTable) 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 (XUserTable) SetPkColumn added in v0.25.0

func (tbl XUserTable) SetPkColumn(pk string) XUserTable

SetPkColumn sets the name of the primary key column. It defaults to "uid". The result is a modified copy of the table; the original is unchanged.

func (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) XUserTable

Using returns a modified Table using the transaction supplied. This is needed when making multiple queries across several tables within a single transaction. The result is a modified copy of the table; the original is unchanged.

func (XUserTable) WithConstraint added in v0.12.0

func (tbl XUserTable) WithConstraint(cc ...constraint.Constraint) XUserTable

WithConstraint returns a modified Table with added data consistency constraints.

func (XUserTable) WithContext added in v0.8.0

func (tbl XUserTable) WithContext(ctx context.Context) XUserTable

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

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

Jump to

Keyboard shortcuts

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