demo

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2018 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const AUserColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const AUserDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const AUserPk = "uid"
View Source
const AddressColumnNames = "id,lines,town,postcode"
View Source
const AddressDataColumnNames = "lines,town,postcode"
View Source
const AddressPk = "id"
View Source
const AssociationColumnNames = "id,name,quality,ref1,ref2,category"
View Source
const AssociationDataColumnNames = "name,quality,ref1,ref2,category"
View Source
const AssociationPk = "id"
View Source
const CUserColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const CUserDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const CUserPk = "uid"
View Source
const DUserColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const DUserDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const DUserPk = "uid"
View Source
const DbCompoundColumnNames = "alpha,beta,category"
View Source
const DbUserColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const DbUserDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const DbUserPk = "uid"
View Source
const HookColumnNames = "" /* 242-byte string literal not displayed */
View Source
const HookDataColumnNames = "" /* 239-byte string literal not displayed */
View Source
const HookPk = "id"
View Source
const IssueColumnNames = "id,number,date,title,bigbody,assignee,state,labels"
View Source
const IssueDataColumnNames = "number,date,title,bigbody,assignee,state,labels"
View Source
const IssuePk = "id"
View Source
const NumAUserColumns = 22
View Source
const NumAUserDataColumns = 21
View Source
const NumAddressColumns = 4
View Source
const NumAddressDataColumns = 3
View Source
const NumAssociationColumns = 6
View Source
const NumAssociationDataColumns = 5
View Source
const NumCUserColumns = 22
View Source
const NumCUserDataColumns = 21
View Source
const NumDUserColumns = 22
View Source
const NumDUserDataColumns = 21
View Source
const NumDbCompoundColumns = 3
View Source
const NumDbCompoundDataColumns = 3
View Source
const NumDbUserColumns = 22
View Source
const NumDbUserDataColumns = 21
View Source
const NumHookColumns = 17
View Source
const NumHookDataColumns = 16
View Source
const NumIssueColumns = 8
View Source
const NumIssueDataColumns = 7
View Source
const NumRUserColumns = 22
View Source
const NumRUserDataColumns = 21
View Source
const NumSUserColumns = 22
View Source
const NumSUserDataColumns = 21
View Source
const NumUUserColumns = 22
View Source
const NumUUserDataColumns = 21
View Source
const NumXUserColumns = 22
View Source
const NumXUserDataColumns = 21
View Source
const RUserColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const RUserDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const RUserPk = "uid"
View Source
const SUserColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const SUserDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const SUserPk = "uid"
View Source
const UUserColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const UUserDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const UUserPk = "uid"
View Source
const XUserColumnNames = "uid,name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const XUserDataColumnNames = "name,emailaddress,addressid,avatar,role,active,admin,fave,lastupdated,i8,u8,i16,u16,i32,u32,i64,u64,f32,f64,token,secret"
View Source
const XUserPk = "uid"

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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB added in v0.8.0

func (tbl AUserTable) DB() *sql.DB

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() *sqlgen2.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() schema.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() sqlgen2.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, value 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, value 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() sqlgen2.TableName

Name gets the table name.

func (AUserTable) Query added in v0.8.0

func (tbl AUserTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl AUserTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

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

func (tbl AUserTable) SliceActive(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]bool, error)

SliceActive gets the Active 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) 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) SliceAdmin added in v0.8.0

func (tbl AUserTable) SliceAdmin(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]bool, error)

SliceAdmin gets the Admin column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceAvatar added in v0.8.0

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

SliceAvatar gets the Avatar column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceEmailaddress added in v0.8.0

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

SliceEmailAddress gets the EmailAddress column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceF32 added in v0.19.0

SliceF32 gets the F32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceF64 added in v0.19.0

SliceF64 gets the F64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceI16 added in v0.19.0

SliceI16 gets the I16 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceI32 added in v0.19.0

SliceI32 gets the I32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceI64 added in v0.19.0

SliceI64 gets the I64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceI8 added in v0.19.0

SliceI8 gets the I8 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceLastupdated added in v0.8.0

func (tbl AUserTable) SliceLastupdated(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

SliceLastUpdated gets the LastUpdated column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceName added in v0.16.0

SliceName gets the Name column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceRole added in v0.10.0

func (tbl AUserTable) SliceRole(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Role, error)

SliceRole gets the Role column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceU16 added in v0.19.0

SliceU16 gets the U16 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceU32 added in v0.19.0

SliceU32 gets the U32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceU64 added in v0.19.0

SliceU64 gets the U64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceU8 added in v0.19.0

SliceU8 gets the U8 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) SliceUid added in v0.8.0

SliceUid gets the Uid column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AUserTable) 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() *sql.Tx

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 *sql.Tx) 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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB added in v0.12.0

func (tbl AddressTable) DB() *sql.DB

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() *sqlgen2.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() schema.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() sqlgen2.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, value string) ([]*Address, error)

GetAddressesByPostcode gets the records with a given postcode value. If not found, *Address will be nil.

func (AddressTable) GetAddressesByTown added in v0.16.0

func (tbl AddressTable) GetAddressesByTown(req require.Requirement, value string) ([]*Address, error)

GetAddressesByTown gets the records with a given town value. If not found, *Address will be 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() sqlgen2.TableName

Name gets the table name.

func (AddressTable) Query added in v0.12.0

func (tbl AddressTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl AddressTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

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 sqlgen2. 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) 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() *sql.Tx

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 *sql.Tx) 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  *string
	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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB

func (tbl AssociationTable) DB() *sql.DB

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() *sqlgen2.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() schema.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() sqlgen2.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() sqlgen2.TableName

Name gets the table name.

func (AssociationTable) Query

func (tbl AssociationTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl AssociationTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

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 sqlgen2. 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) SliceCategory

SliceCategory gets the Category column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AssociationTable) SliceId

SliceId gets the Id column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AssociationTable) SliceName

SliceName gets the Name column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AssociationTable) SliceQuality

SliceQuality gets the Quality column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AssociationTable) SliceRef1

SliceRef1 gets the Ref1 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AssociationTable) SliceRef2

SliceRef2 gets the Ref2 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (AssociationTable) 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() *sql.Tx

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

func (tbl AssociationTable) Using(tx *sql.Tx) AssociationTable

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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB added in v0.8.0

func (tbl CUserTable) DB() *sql.DB

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() *sqlgen2.Database

Database gets the shared database information.

func (CUserTable) Dialect added in v0.8.0

func (tbl CUserTable) Dialect() schema.Dialect

Dialect gets the database dialect.

func (CUserTable) Execer added in v0.12.0

func (tbl CUserTable) Execer() sqlgen2.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() sqlgen2.TableName

Name gets the table name.

func (CUserTable) Query added in v0.8.0

func (tbl CUserTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl CUserTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

func (CUserTable) Tx added in v0.8.0

func (tbl CUserTable) Tx() *sql.Tx

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 *sql.Tx) 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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB added in v0.8.0

func (tbl DUserTable) DB() *sql.DB

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() *sqlgen2.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() schema.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() sqlgen2.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() sqlgen2.TableName

Name gets the table name.

func (DUserTable) Query added in v0.8.0

func (tbl DUserTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl DUserTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

func (DUserTable) Tx added in v0.8.0

func (tbl DUserTable) Tx() *sql.Tx

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 *sql.Tx) 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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB

func (tbl DbCompoundTable) DB() *sql.DB

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() *sqlgen2.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() schema.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() sqlgen2.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) 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() sqlgen2.TableName

Name gets the table name.

func (DbCompoundTable) Query

func (tbl DbCompoundTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl DbCompoundTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

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 sqlgen2. 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) SliceCategory

SliceCategory gets the Category column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbCompoundTable) 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() *sql.Tx

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

func (tbl DbCompoundTable) Using(tx *sql.Tx) DbCompoundTable

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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.Database) DbUserTable

NewDbUserTable 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 (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) DB

func (tbl DbUserTable) DB() *sql.DB

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() *sqlgen2.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() schema.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() sqlgen2.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, value 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, value 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() sqlgen2.TableName

Name gets the table name.

func (DbUserTable) Query

func (tbl DbUserTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl DbUserTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

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 sqlgen2. 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) SliceActive

func (tbl DbUserTable) SliceActive(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]bool, error)

SliceActive gets the Active 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) 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) SliceAdmin

func (tbl DbUserTable) SliceAdmin(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]bool, error)

SliceAdmin gets the Admin column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceAvatar

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

SliceAvatar gets the Avatar column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceEmailaddress added in v0.8.0

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

SliceEmailAddress gets the EmailAddress column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceF32 added in v0.19.0

SliceF32 gets the F32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceF64 added in v0.19.0

SliceF64 gets the F64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceI16 added in v0.19.0

SliceI16 gets the I16 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceI32 added in v0.19.0

SliceI32 gets the I32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceI64 added in v0.19.0

SliceI64 gets the I64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceI8 added in v0.19.0

SliceI8 gets the I8 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceLastupdated added in v0.8.0

func (tbl DbUserTable) SliceLastupdated(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]int64, error)

SliceLastUpdated gets the LastUpdated column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceName added in v0.16.0

SliceName gets the Name column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceRole added in v0.10.0

func (tbl DbUserTable) SliceRole(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Role, error)

SliceRole gets the Role column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceU16 added in v0.19.0

SliceU16 gets the U16 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceU32 added in v0.19.0

SliceU32 gets the U32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceU64 added in v0.19.0

SliceU64 gets the U64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceU8 added in v0.19.0

SliceU8 gets the U8 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) SliceUid

SliceUid gets the Uid column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (DbUserTable) 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() *sql.Tx

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 *sql.Tx) 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 HookTable

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

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

func CopyTableAsHookTable added in v0.8.0

func CopyTableAsHookTable(origin sqlgen2.Table) HookTable

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

It serves to provide methods appropriate for 'Hook'. This is most useful when this is used to represent a join result. In such cases, there won't be any need for DDL methods, nor Exec, Insert, Update or Delete.

func NewHookTable

func NewHookTable(name sqlgen2.TableName, d *sqlgen2.Database) HookTable

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

func (HookTable) BeginTx

func (tbl HookTable) BeginTx(opts *sql.TxOptions) (HookTable, 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 (HookTable) Constraints added in v0.14.0

func (tbl HookTable) Constraints() constraint.Constraints

Constraints returns the table's constraints.

func (HookTable) Count

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

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

func (HookTable) CountWhere added in v0.9.0

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

CountWhere counts Hooks in the table that match a 'where' clause. Use a blank string for the 'where' argument if it is not needed.

The args are for any placeholder parameters in the query.

func (HookTable) CreateTable

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

CreateTable creates the table.

func (HookTable) DB

func (tbl HookTable) DB() *sql.DB

DB gets the wrapped database handle, provided this is not within a transaction. Panics if it is in the wrong state - use IsTx() if necessary.

func (HookTable) Database added in v0.12.0

func (tbl HookTable) Database() *sqlgen2.Database

Database gets the shared database information.

func (HookTable) Delete

func (tbl HookTable) Delete(req require.Requirement, wh where.Expression) (int64, error)

Delete deletes one or more rows from the table, given a 'where' clause. Use a nil value for the 'wh' argument if it is not needed (very risky!).

func (HookTable) DeleteHooks added in v0.8.0

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

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

func (HookTable) Dialect

func (tbl HookTable) Dialect() schema.Dialect

Dialect gets the database dialect.

func (HookTable) DropTable

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

DropTable drops the table, destroying all its data.

func (HookTable) Exec

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

Exec executes a query without returning any rows. It returns the number of rows affected (if the database driver supports this).

The args are for any placeholder parameters in the query.

func (HookTable) Execer added in v0.12.0

func (tbl HookTable) Execer() sqlgen2.Execer

Execer gets the wrapped database or transaction handle.

func (HookTable) Fetch added in v0.17.0

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

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

func (HookTable) GetHookById added in v0.16.0

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

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

func (HookTable) GetHooksById added in v0.16.0

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

GetHooksById gets records from the table according to a list of primary keys. Although the list of ids can be arbitrarily long, there are practical limits; note that Oracle DB has a limit of 1000.

It places a requirement, which may be nil, on the size of the expected results: in particular, require.All controls whether an error is generated not all the ids produce a result.

func (HookTable) Insert

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

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

func (HookTable) IsTx

func (tbl HookTable) IsTx() bool

IsTx tests whether this is within a transaction.

func (HookTable) Logger

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

Logger gets the trace logger.

func (HookTable) Name

func (tbl HookTable) Name() sqlgen2.TableName

Name gets the table name.

func (HookTable) Query

func (tbl HookTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

func (HookTable) QueryOneNullFloat64 added in v0.9.0

func (tbl HookTable) QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error)

QueryOneNullFloat64 is a low-level access method for one float64. This can be used for 'AVG(...)' queries and such like. If the query selected many rows, only the first is returned; the rest are discarded. If not found, the result will be invalid.

Note that this applies ReplaceTableName to the query string.

The args are for any placeholder parameters in the query.

func (HookTable) QueryOneNullInt64 added in v0.9.0

func (tbl HookTable) QueryOneNullInt64(req require.Requirement, query string, args ...interface{}) (result sql.NullInt64, err error)

QueryOneNullInt64 is a low-level access method for one int64. This can be used for 'COUNT(1)' queries and such like. If the query selected many rows, only the first is returned; the rest are discarded. If not found, the result will be invalid.

Note that this applies ReplaceTableName to the query string.

The args are for any placeholder parameters in the query.

func (HookTable) QueryOneNullString added in v0.9.0

func (tbl HookTable) QueryOneNullString(req require.Requirement, query string, args ...interface{}) (result sql.NullString, err error)

QueryOneNullString is a low-level access method for one string. This can be used for function queries and such like. If the query selected many rows, only the first is returned; the rest are discarded. If not found, the result will be invalid.

Note that this applies ReplaceTableName to the query string.

The args are for any placeholder parameters in the query.

func (HookTable) ReplaceTableName added in v0.9.0

func (tbl HookTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

func (HookTable) Select

Select allows Hooks to be obtained from the table that match a 'where' clause. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

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

func (HookTable) SelectOne

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

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

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

func (HookTable) SelectOneWhere added in v0.9.0

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

SelectOneWhere allows a single 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 (HookTable) SelectWhere added in v0.9.0

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

SelectWhere allows Hooks to be obtained from the table that match a 'where' clause. Any order, limit or offset clauses can be supplied in 'orderBy'. Use blank strings for the 'where' and/or 'orderBy' arguments if they are not needed.

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

The args are for any placeholder parameters in the query.

func (HookTable) SliceAfter added in v0.8.0

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

SliceAfter gets the After column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceBefore added in v0.8.0

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

SliceBefore gets the Before column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceCategory

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

SliceCategory gets the Category column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceCommitId added in v0.8.0

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

SliceID gets the ID column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceCreated

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

SliceCreated gets the Created column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceDeleted

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

SliceDeleted gets the Deleted column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceForced

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

SliceForced gets the Forced column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceHeadCommitAuthorEmail added in v0.8.0

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

SliceEmail gets the Email column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceHeadCommitAuthorName added in v0.8.0

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

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

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

SliceUsername gets the Username column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceHeadCommitCommitterEmail added in v0.8.0

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

SliceEmail gets the Email column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceHeadCommitCommitterName added in v0.8.0

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

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

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

SliceUsername gets the Username column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceId

SliceId gets the Id column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceMessage added in v0.8.0

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

SliceMessage gets the Message column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceSha

SliceSha gets the Sha column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) SliceTimestamp added in v0.8.0

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

SliceTimestamp gets the Timestamp column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (HookTable) Truncate

func (tbl HookTable) Truncate(force bool) (err error)

Truncate drops every record from the table, if possible. It might fail if constraints exist that prevent some or all rows from being deleted; use the force option to override this.

When 'force' is set true, be aware of the following consequences. When using Mysql, foreign keys in other tables can be left dangling. When using Postgres, a cascade happens, so all 'adjacent' tables (i.e. linked by foreign keys) are also truncated.

func (HookTable) Tx

func (tbl HookTable) Tx() *sql.Tx

Tx gets the wrapped transaction handle, provided this is within a transaction. Panics if it is in the wrong state - use IsTx() if necessary.

func (HookTable) Update

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

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

func (HookTable) UpdateFields

func (tbl HookTable) UpdateFields(req require.Requirement, wh where.Expression, fields ...sql.NamedArg) (int64, error)

UpdateFields updates one or more columns, given a 'where' clause.

Use a nil value for the 'wh' argument if it is not needed (very risky!).

func (HookTable) Using added in v0.9.0

func (tbl HookTable) Using(tx *sql.Tx) HookTable

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

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

WithConstraint returns a modified Table with added data consistency constraints.

func (HookTable) WithContext

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

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

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

func (HookTable) WithPrefix

func (tbl HookTable) WithPrefix(pfx string) HookTable

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

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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB

func (tbl IssueTable) DB() *sql.DB

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() *sqlgen2.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() schema.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() sqlgen2.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, value string) ([]*Issue, error)

GetIssuesByAssignee gets the records with a given assignee value. If not found, *Issue will be 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() sqlgen2.TableName

Name gets the table name.

func (IssueTable) Query

func (tbl IssueTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl IssueTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

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 sqlgen2. 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) 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)

SliceBody gets the Body 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) SliceDate

func (tbl IssueTable) SliceDate(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Date, error)

SliceDate gets the Date 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() *sql.Tx

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 *sql.Tx) 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
	U8  uint8
	I16 int16
	U16 uint16
	I32 int32
	U32 uint32
	I64 int64
	U64 uint64
	F32 float32
	F64 float64
}

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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB added in v0.8.0

func (tbl RUserTable) DB() *sql.DB

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() *sqlgen2.Database

Database gets the shared database information.

func (RUserTable) Dialect added in v0.8.0

func (tbl RUserTable) Dialect() schema.Dialect

Dialect gets the database dialect.

func (RUserTable) Execer added in v0.12.0

func (tbl RUserTable) Execer() sqlgen2.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, value 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, value 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() sqlgen2.TableName

Name gets the table name.

func (RUserTable) Query added in v0.8.0

func (tbl RUserTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl RUserTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

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

func (tbl RUserTable) Tx() *sql.Tx

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 *sql.Tx) 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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB added in v0.8.0

func (tbl SUserTable) DB() *sql.DB

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() *sqlgen2.Database

Database gets the shared database information.

func (SUserTable) Dialect added in v0.8.0

func (tbl SUserTable) Dialect() schema.Dialect

Dialect gets the database dialect.

func (SUserTable) Execer added in v0.12.0

func (tbl SUserTable) Execer() sqlgen2.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() sqlgen2.TableName

Name gets the table name.

func (SUserTable) Query added in v0.8.0

func (tbl SUserTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl SUserTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

func (SUserTable) SliceActive added in v0.8.0

func (tbl SUserTable) SliceActive(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]bool, error)

SliceActive gets the Active 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) 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) SliceAdmin added in v0.8.0

func (tbl SUserTable) SliceAdmin(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]bool, error)

SliceAdmin gets the Admin 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) SliceF32 added in v0.19.0

SliceF32 gets the F32 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (SUserTable) SliceF64 added in v0.19.0

SliceF64 gets the F64 column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

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

func (tbl SUserTable) SliceRole(req require.Requirement, wh where.Expression, qc where.QueryConstraint) ([]Role, error)

SliceRole gets the Role column for all rows that match the 'where' condition. Any order, limit or offset clauses can be supplied in query constraint 'qc'. Use nil values for the 'wh' and/or 'qc' arguments if they are not needed.

func (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() *sql.Tx

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 *sql.Tx) 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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB added in v0.8.0

func (tbl UUserTable) DB() *sql.DB

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() *sqlgen2.Database

Database gets the shared database information.

func (UUserTable) Dialect added in v0.8.0

func (tbl UUserTable) Dialect() schema.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() sqlgen2.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() sqlgen2.TableName

Name gets the table name.

func (UUserTable) Query added in v0.8.0

func (tbl UUserTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl UUserTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

func (UUserTable) Tx added in v0.8.0

func (tbl UUserTable) Tx() *sql.Tx

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 *sql.Tx) 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 sqlgen2.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 sqlgen2.TableName, d *sqlgen2.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) DB added in v0.8.0

func (tbl XUserTable) DB() *sql.DB

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() *sqlgen2.Database

Database gets the shared database information.

func (XUserTable) Dialect added in v0.8.0

func (tbl XUserTable) Dialect() schema.Dialect

Dialect gets the database dialect.

func (XUserTable) Execer added in v0.12.0

func (tbl XUserTable) Execer() sqlgen2.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() sqlgen2.TableName

Name gets the table name.

func (XUserTable) Query added in v0.8.0

func (tbl XUserTable) Query(query string, args ...interface{}) (*sql.Rows, 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.

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

func (tbl XUserTable) ReplaceTableName(query string) string

ReplaceTableName replaces all occurrences of "{TABLE}" with the table's name.

func (XUserTable) Tx added in v0.8.0

func (tbl XUserTable) Tx() *sql.Tx

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 *sql.Tx) 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