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


TypeScript ConnectionPool.close方法代碼示例

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


在下文中一共展示了ConnectionPool.close方法的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: 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


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