当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mssql.ConnectionPool类代码示例

本文整理汇总了TypeScript中mssql.ConnectionPool的典型用法代码示例。如果您正苦于以下问题:TypeScript ConnectionPool类的具体用法?TypeScript ConnectionPool怎么用?TypeScript ConnectionPool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ConnectionPool类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: async

    mergeFunc: async (context) => {
        let mergeSuccess = false;
        const currentTime = moment().format("YYYY-MM-DD HH:mm:ss");

        const commonCols = [
            'store_code', 'pos_no', 'receipt_no', 'no1', 'no2', 'type', 'payment_no', 'performance_id', 'seat_code', 
            'performance_type', 'performance_day', 'start_time', 'sales_date', 'section_code', 'plu_code', 'item_name', 
            'sales_amount', 'unit_price', 'unit', 'sum_amount', 'payment_type', 'cash', 'payment_type1', 'payment_type2', 
            'payment_type3', 'payment_type4', 'payment_type5', 'payment_type6', 'payment_type7', 'payment_type8',
            'customer1', 'customer2', 'entry_flg', 'entry_date'
        ];

        let mergeCols: string[] = [];
        commonCols.forEach(col => mergeCols.push(`${col} = src.${col}`));

        const server = new sql.ConnectionPool(configs.mssql);
        await server.connect().then(async pool => {

            await new sql.Request(pool).query(`
                INSERT pos_sales (${[...commonCols, ...['created_at']].join(',')})  
                SELECT ${[...commonCols, ...[`'${currentTime}'`]].join(',')} 
                FROM pos_sales_tmp   
                WHERE NOT EXISTS (
                    SELECT * FROM pos_sales ps 
                    WHERE IsNull(ps.payment_no, '') = IsNull(pos_sales_tmp.payment_no, '') 
                        AND IsNull(ps.seat_code, '') = IsNull(pos_sales_tmp.seat_code, '') 
                        AND IsNull(ps.performance_day, '') = IsNull(pos_sales_tmp.performance_day, '') 
                        AND IsNull(ps.receipt_no, '') = IsNull(pos_sales_tmp.receipt_no, '') 
                        AND IsNull(ps.no1, '') = IsNull(pos_sales_tmp.no1, '')
                ) AND pos_sales_tmp.uuid = '${context.funcId}';`);

            await new sql.Request(pool).query(`
                UPDATE tgt 
                SET ${[...mergeCols, ...[`updated_at = '${currentTime}'`]].join(',')}
                FROM dbo.pos_sales AS tgt
                INNER JOIN pos_sales_tmp AS src ON (
                    src.uuid = '${context.funcId}' 
                    AND IsNull(tgt.payment_no, '') = IsNull(src.payment_no, '')
                    AND IsNull(tgt.seat_code, '') = IsNull(src.seat_code, '') 
                    AND IsNull(tgt.performance_day, '') = IsNull(src.performance_day, '')
                    AND IsNull(tgt.receipt_no, '') = IsNull(src.receipt_no, '')
                    AND IsNull(tgt.no1, '') = IsNull(src.no1, '')
                );`);

            await new sql.Request(pool).query(`DELETE FROM pos_sales_tmp WHERE uuid = '${context.funcId}';`);
        }).then(async result => {
            mergeSuccess = true;
            context.log(`${context.bindingData.name}ファイル: マージしました。`);

            await posSalesRepository.processComplete(context);
        }).catch(err => {
            mergeSuccess = false;
            context.log(`${context.bindingData.name}ファイル: マージ分はエラーが出ています。`);
            Logs.writeErrorLog(context, `${context.bindingData.name}ファイル` + "\n" + err.stack);
        });

        server.close();
        return mergeSuccess;
    },
开发者ID:motionpicture,项目名称:ttts-functions,代码行数:59,代码来源:pos_sales.ts

示例3: test_classes_extend_eventemitter

function test_classes_extend_eventemitter() {
    var connection: sql.ConnectionPool = new sql.ConnectionPool(config);
    var transaction = new sql.Transaction();
    var request = new sql.Request();
    var preparedStatment = new sql.PreparedStatement();

    connection.on('connect', () => { });
    transaction.on('begin', () => { });
    transaction.on('commit', () => { });
    transaction.on('rollback', () => { });
    request.on('done', () => { });
    request.on('error', () => { });

    preparedStatment.on('error', () => { })
}
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:15,代码来源:mssql-tests.ts


注:本文中的mssql.ConnectionPool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。