AddForeignKey creates a Query that can be used to add a foreign key constraint to a table. The length of cols and refCols must be the same as they refer to the primary and referential columns. The optional "options" parameters will be appended to the SQL statement. They can be used to specify options such as "ON DELETE CASCADE".
Rest
...options: string[]CreateTable creates a Query that represents a CREATE TABLE SQL statement. The keys of cols are the column names, while the values of cols are the corresponding column types. The optional "options" parameters will be appended to the generated SQL statement.
Rest
...options: string[]Delete creates a Query that represents a DELETE SQL statement. If the "where" expression is nil, the DELETE SQL statement will have no WHERE clause (be careful in this case as the SQL statement will delete ALL rows in the table).
ModelQuery returns a new ModelQuery object that can be used to perform model insertion, update, and deletion. The parameter to this method should be a pointer to the model struct that needs to be inserted, updated, or deleted.
QueryBuilder returns the query builder supporting the current DB.
Select returns a new SelectQuery object that can be used to build a SELECT statement. The parameters to this method should be the list column names to be selected. A column name may have an optional alias name. For example, Select("id", "my_name AS name").
Rest
..._arg0: string[]TransactionalContext starts a transaction and executes the given function with the given context and transaction options. If the function returns an error, the transaction will be rolled back. Otherwise, the transaction will be committed.
Update creates a Query that represents an UPDATE SQL statement. The keys of cols are the column names, while the values of cols are the corresponding new column values. If the "where" expression is nil, the UPDATE SQL statement will have no WHERE clause (be careful in this case as the SQL statement will update ALL rows in the table).
Upsert creates a Query that represents an UPSERT SQL statement. Upsert inserts a row into the table if the primary key or unique index is not found. Otherwise it will update the row with the new values. The keys of cols are the column names, while the values of cols are the corresponding column values to be inserted.
Rest
...constraints: string[]ExecLogFunc is called each time when a SQL statement is executed.
FieldMapper maps struct fields to DB columns. Defaults to DefaultFieldMapFunc.
LogFunc logs the SQL statements being executed. Defaults to nil, meaning no logging.
PerfFunc logs the SQL execution time. Defaults to nil, meaning no performance profiling. Deprecated: Please use QueryLogFunc and ExecLogFunc instead.
QueryLogFunc is called each time when performing a SQL query that returns data.
TableMapper maps structs to table names. Defaults to GetTableName.
Generated using TypeDoc
DB enhances sql.DB by providing a set of DB-agnostic query building methods. DB allows easier query building and population of data into Go variables.