Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Sql

sql操作接口

Hierarchy

  • Sql

Index

Methods

Methods

exec

  • 执行sql语句, 使用'limit offset, count'语句来进行查询分页, 支持限制查询返回的记录条数,通过offset值指定从第多少条开始,count指定总共返回多少条记录。 在不指定offset, count情况,默认值为offset=0, count=5000,意味着查询返回结果集的前5000条。 count最大值可设置为10000条,意味着该查询接口最多只能返回查询结果集的前10000条。

    Parameters

    • stmt: string

      sql

    • Optional options: SqlOptions

      sql执行选项

    Returns Record[]

    记录集

execute

  • 执行sql语句, 使用'limit offset, count'语句来进行查询分页, 支持限制查询返回的记录条数,通过offset值指定从第多少条开始,count指定总共返回多少条记录。 在不指定offset, count情况,默认值为offset=0, count=5000,意味着查询返回结果集的前5000条。 count最大值可设置为10000条,意味着该查询接口最多只能返回查询结果集的前10000条。

    example
    
    import * as db from 'db';
    
    @useObject(['student__cst'])
    class Demo {
       run(): void {
           let se = db.sql();
           let value = se.execute("select name, age__CST from student__CST where name = ? and age__CST = ?", { params: ['hello2', 'age2']});
       }
    }
    
    let demo = new Demo();
    demo.run();
    

    Parameters

    • stmt: string

      sql

    • Optional options: SqlOptions

      sql执行选项

    Returns ResultSet

    ResultSet

explain

  • 输出一个sql执行计划

    example
    
    import * as db from 'db';
    let se = db.sql();
    let plans = se.explain("select name, age__CST from student__CST where name = ? and age__CST = ?", { params: ['hello2', 'age2']});
    

    Parameters

    • stmt: string

      sql

    • Optional options: SqlOptions

      执行选项

    Returns Record[]

    执行计划信息