A class for building sql
Parameter with
?
means optional
- buildCreateTableSql
- build create table sql
- parameter:
- null
- return
string[]
- buildInsertSql
- build insert sql
- parameters:
- index:
number
, table index - fields:
string[]
, fields you want to set when insert - values:
any[]
, values you want to set when insert
- index:
- return
object
|null
- sql:
string
- replacements?:
any[]
- alias?:
string
- sql:
- buildDeleteSqlByPks
- build delete sql by primary keys
- parameters:
- index:
number
, table index - pkValues:
any[]
, primary key values
- index:
- return
object
|null
- sql:
string
- replacements?:
any[]
- alias?:
string
- sql:
- buildDeleteSqlByWhereClause
- build delete sql by where clause
- parameters:
- index:
number
, table index - whereClause:
string
, where clause
- index:
- return
object
|null
- sql:
string
- replacements?:
any[]
- alias?:
string
- sql:
- buildUpdateSqlByPks
- build update sql by primary keys
- parameters:
- index:
number
, table index - updateFields:
string[]
, fields you want to set when update - updateValues:
any[]
, values you want to set when update - pkValues:
any[]
, primary key values
- index:
- return
object
|null
- sql:
string
- replacements?:
any[]
- alias?:
string
- sql:
- buildUpdateSqlByWhereClause
- build update sql by where clause
- parameters:
- index:
number
, table index - updateFields:
string[]
, fields you want to set when update - updateValues:
any[]
, values you want to set when update - whereClause?:
string
, where clause
- index:
- return
object
|null
- sql:
string
- replacements?:
any[]
- alias?:
string
- sql:
- buildQuerySqlByPks
- build single query sql for one table by primary keys
- parameters:
- index:
number
, table index - selectFields:
string[]
|'*'
, fields you want to select - pkValues:
any[]
, primary key values - options?:
object
- orderBy?:
array
, for sort by clause- field:
string
, sorting field - sequence:
string
, either of'ASC'
and'DESC'
, default'ASC'
- field:
- distinct?:
boolean
, if true then will leave 1 row with same data - limit?:
number
, query counts, for pagination - offset?:
number
, query offset, for pagination
- orderBy?:
- index:
- return
object
|null
- sql:
string
- replacements?:
any[]
- alias?:
string
- sql:
- buildQuerySqlByWhereClause
- build single query sql for one table by where clause
- parameters:
- index:
number
, table index - selectFields:
string[]
|'*'
, fields you want to select - whereClause?:
string
, where clause - options?:
object
- orderBy?:
array
, for sort by clause- field:
string
, sorting field - sequence:
string
, either of'ASC'
and'DESC'
, default'ASC'
- field:
- distinct?:
boolean
, if true then will leave 1 row with same data - limit?:
number
, query counts, for pagination - offset?:
number
, query offset, for pagination
- orderBy?:
- index:
- return
object
|null
- sql:
string
- replacements?:
any[]
- alias?:
string
- sql:
- buildModelQuerySqlByWhereClause
- build delete sql by where clause
- parameters:
- selectFields:
string[]
|'*'
, fields you want to select - whereClause?:
string
, where clause - options?:
object
- orderBy?:
array
, for sort by clause- field:
string
, sorting field - sequence:
string
, either of'ASC'
and'DESC'
, default'ASC'
- field:
- distinct?:
boolean
, if true then will leave 1 row with same data - limit?:
number
, query counts, for pagination - offset?:
number
, query offset, for pagination
- orderBy?:
- selectFields:
- return
object
|null
- sql:
string
- replacements?:
any[]
- alias?:
string
- sql:
- checkTableColumnExist
- check whether the column exists in the data table
- parameters:
- tableName:
string
, the name of data table - columnName:
string
, the column name you will check
- tableName:
- return
boolean