當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Request.batch方法代碼示例

本文整理匯總了TypeScript中mssql.Request.batch方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Request.batch方法的具體用法?TypeScript Request.batch怎麽用?TypeScript Request.batch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mssql.Request的用法示例。


在下文中一共展示了Request.batch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test_promise_returns

function test_promise_returns() {
    // Methods return a promises if the callback is omitted.
    var connection: sql.ConnectionPool = new sql.ConnectionPool(config);
    connection.connect().then(() => { });
    connection.close().then(() => { });

    var preparedStatment = new sql.PreparedStatement(connection);
    preparedStatment.prepare("SELECT @myValue").then(() => { });
    preparedStatment.execute({ myValue: 1 }).then((recordSet) => { });
    preparedStatment.unprepare().then(() => { });

    var transaction = new sql.Transaction(connection);
    transaction.begin().then(() => { });
    transaction.commit().then(() => { });
    transaction.rollback().then(() => { });

    var request = new sql.Request();
    request.batch('create procedure #temporary as select * from table').then((recordset) => { });
    request.batch<Entity>('create procedure #temporary as select * from table;select 1 as value').then((recordset) => { });
    request.bulk(new sql.Table("table_name")).then(() => { });
    request.query('SELECT 1').then((recordset) => { });
    request.query`SELECT ${1} as value`.then(res => { });
    request.query<Entity>('SELECT 1 as value').then(res => { });
    request.execute('procedure_name').then((recordset) => { });
}
開發者ID:csrakowski,項目名稱:DefinitelyTyped,代碼行數:25,代碼來源:mssql-tests.ts

示例2: function

const request2 = new sql.Request();
request2.query('select 1 as number', function(err, recordset: sql.RecordSet<MyClass>) {
    // ... error checks

    console.log(recordset[0].number); // return 1

    // ...
});

/**
 * batch https://github.com/patriksimek/node-mssql#batch-batch-callback
 */
const request3 = new sql.Request();
request3.batch('create procedure #temporary as select * from table', function(err, recordset) {
    // ... error checks
});

/**
 * bulk https://github.com/patriksimek/node-mssql#bulktable-callback
 */
const table = new sql.Table('table_name'); // or temporary table, e.g. #temptable
table.create = true;
table.columns.add('a', sql.Int, {nullable: true, primary: true});
table.columns.add('b', sql.VarChar(50), {nullable: false});
table.rows.add(777, 'test');

const request4 = new sql.Request();
request4.bulk(table, function(err, rowCount) {
    // ... error checks
});
開發者ID:typed-contrib,項目名稱:node-mssql,代碼行數:30,代碼來源:request.ts


注:本文中的mssql.Request.batch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。