Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Select

查询

export
class

Select

Hierarchy

  • Select

Index

Methods

Static select

  • 单个SQL查询

    static
    memberof

    Select

    example
    tbl1表结构:
    create table tbl1 (
     f1 int,
     f2 int,
     f3 int
    )
    例1:
    let list = await Select.select(conn, {
      sql: `select * from tbl1 where f1=? and f2=?`,
      where: [1, 2]
    });
    

    Parameters

    Returns Promise<any>

    Promise对象

Static Private selectBase

Static selectCount

  • 查询单个SQL,返回行数

    static
    memberof

    Select

    create table tbl1 (
     f1 int,
     f2 int,
     f3 int
    )
    let result = await Select.selectCount(conn, {
      sql: `select * from tbl1 where f1=?`,
      where: [1]
    });
    

    Parameters

    Returns Promise<number>

    Promise对象

Static selectGUID

  • selectGUID(conn: ConnectionPool): Promise<string>
  • 获取GUIID

    static
    memberof

    Select

    Parameters

    • conn: ConnectionPool

      数据库连接

    Returns Promise<string>

Static selectOneValue

  • 查询第一条数据的第一个字段

    static
    memberof

    Select

    create table tbl1 (
     f1 int,
     f2 int,
     f3 int
    )
    let result = await Select.selectOneValue(conn, {
      sql: `select * from tbl1 where f1=?`,
      where: [1]
    });
    结果,返回值为满足条件的第一条数据的f1字段值
    

    Parameters

    Returns Promise<any>

    Promise对象

Static selectSplitPage

  • 分页查询

    static
    memberof

    Select

    create table tbl1 (
     f1 int,
     f2 int,
     f3 int
    )
    let result = await Select.selectSplitPage(conn, {
      sql: `select * from tbl1 where f1=?`,
      where: [1],
      pageSize: 10,
      index: 0
    });
    

    Parameters

    Returns Promise<SplitPageResultModel>

    Promise对象

Static selectTop1

  • 查询单个SQL,返回第一条数据

    static
    memberof

    Select

    example
    create table tbl1 (
     f1 int,
     f2 int,
     f3 int
    )
    let result = await Select.selectTop1(conn, {
      sql: `select * from tbl1 where f1=?`,
      where: [1]
    });
    

    Parameters

    Returns Promise<any>

    Promise对象

Static selects

  • 多个SQL查询

    static
    memberof

    Select

    example
    tbl1表结构:
    create table tbl1 (
     f1 int,
     f2 int,
     f3 int
    )
    例1:
    let list = await Select.selects(conn, [{
      sql: `select * from tbl1 where f1=?`,
      where: [1]
     }, {
      sql: `select * from tbl1 where f1=?`,
      where: [2]
    }]);
    

    Parameters

    • conn: ConnectionPool

      数据库连接对象

    • params: SelectParamsModel[]

      查询参数

    Returns Promise<any[][]>

    Promise对象