Skip to content

Latest commit

 

History

History
131 lines (126 loc) · 4.15 KB

LibSQLBuilder.md

File metadata and controls

131 lines (126 loc) · 4.15 KB

LibSQLBuilder

A class for building sql

Parameter with ? means optional

API

  • 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
    • return
      • object | null
        • sql: string
        • replacements?: any[]
        • alias?: string
  • buildDeleteSqlByPks
    • build delete sql by primary keys
    • parameters:
      • index: number, table index
      • pkValues: any[], primary key values
    • return
      • object | null
        • sql: string
        • replacements?: any[]
        • alias?: string
  • buildDeleteSqlByWhereClause
    • build delete sql by where clause
    • parameters:
      • index: number, table index
      • whereClause: string, where clause
    • return
      • object | null
        • sql: string
        • replacements?: any[]
        • alias?: string
  • 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
    • return
      • object | null
        • sql: string
        • replacements?: any[]
        • alias?: string
  • 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
    • return
      • object | null
        • sql: string
        • replacements?: any[]
        • alias?: string
  • 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'
        • distinct?: boolean, if true then will leave 1 row with same data
        • limit?: number, query counts, for pagination
        • offset?: number, query offset, for pagination
    • return
      • object | null
        • sql: string
        • replacements?: any[]
        • alias?: string
  • 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'
        • distinct?: boolean, if true then will leave 1 row with same data
        • limit?: number, query counts, for pagination
        • offset?: number, query offset, for pagination
    • return
      • object | null
        • sql: string
        • replacements?: any[]
        • alias?: string
  • 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'
        • distinct?: boolean, if true then will leave 1 row with same data
        • limit?: number, query counts, for pagination
        • offset?: number, query offset, for pagination
    • return
      • object | null
        • sql: string
        • replacements?: any[]
        • alias?: string
  • 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
    • return
      • boolean