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


TypeScript tedious.Request类代码示例

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


在下文中一共展示了Request类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: callback

        this.pool.acquire(function (err, connection) {
            if (err)
                console.error(err);

            var request = new tedious.Request(            
            `
                SELECT * FROM [dbo].[Users] WHERE UserId = @UserId AND ApiKey = @ApiKey
            `,function(err, rowCount){
                if(rowCount === 0) {
                    console.log('Unauthenticated error for user: %s', userId);
                    callback(false);
                }
                else {
                    console.log('User authorised');
                    callback(true);
                }
                connection.release();    
            });

            var TYPES = tedious.TYPES;

            request.addParameter('UserId', TYPES.NVarChar, userId);
            request.addParameter('ApiKey', TYPES.NVarChar, apiKey);

            connection.execSql(request);      
        });
开发者ID:MattGauler,项目名称:support-portal-uat,代码行数:26,代码来源:dbManager.ts

示例2: function

        this.pool.acquire(function (err, connection) {
            if (err)
                console.error(err);
            
            var request = new tedious.Request(queryString, function(err, rowCount){
                if(err) {
                    console.error(err);
                }
                else {
                    console.log(rowCount + ' results found');    
                }
                callback(err,result);
                connection.release();    
            });
            
            request.on('row', function(columns){
                var row = {};
                    
                columns.forEach(function(column) {
                    if (column.value === null) {
                        console.log('NULL');
                    } else {
                        row[column.metadata.colName] = column.value;
                    }
                });

                result.push(row);
            });
            
            var TYPES = tedious.TYPES;

            connection.execSql(request);
            
        })    
开发者ID:MattGauler,项目名称:support-portal-uat,代码行数:34,代码来源:dbManager.ts

示例3:

 connection.on('connect', err => {
     var request = new tedious.Request(sql.GetAuthorDetails, (err, rc, rows) => {
         if (err){
             console.log(err);
             res.status(500).send("database error");
             connection.close();
             return;
         }
         if (!rc){
             res.status(404).send("author not found");
             connection.close();
             return;
         }
             
         var author = {
             id: rows[0].ID.value,
             name: rows[0].Name.value,
             books: []
         };
         
         author.books = rows.slice(1).map(row => {
             return {
                 id :row.ID.value,
                 title: row.Title.value
             }
         });
         
         res.json(author);    
         connection.close();
     });
     request.addParameter("authorId",tedious.TYPES.Int, authorId);
     connection.execSql(request);
 });
开发者ID:sweko,项目名称:WebDemo,代码行数:33,代码来源:server.ts

示例4: function

        managers.dbManager.allowRequest(userId, apiKey, function(authorised) {
            if(!authorised) {
                res.status(500).send();
            }
            else {
                var request = new Request('dbo.UpdatePilotDevices',
                    function(err, rowCount) {
                        if (err) {
                            console.log(err);
                            res.status(500).send("Error");
                        }
                        else {
                            console.log('Complete: %s row(s) returned', rowCount);
                            connection.close();
                            res.send('Complete: ' + rowCount + ' row(s) returned');
                        }
                    }
                );

                request.addParameter('DeviceId', TYPES.NVarChar, deviceId);
                request.addParameter('IsPilot', TYPES.NVarChar, pilotValue);

                connection.callProcedure(request);
            }
        });
开发者ID:MattGauler,项目名称:support-portal-uat,代码行数:25,代码来源:markPilot.ts

示例5: function

        managers.dbManager.allowRequest(userId, apiKey, function(authorised) {
            if(!authorised) {
                res.status(500).send();
            }
            else {
                var result = [];

                var request = new Request(
                    `
                    Select
                        *
                    from
                        SupportRequest
                    where
                        MessageID = @requestMessageId
                    `,
                    function(err, rowCount) {
                        if (err) {
                            console.log(err);
                            res.status(500).send("Error");
                        }
                        else {
                            console.log('Complete: %s row(s) returned', rowCount);
                            connection.close();
                            res.setHeader('content-type', 'application/x-www-form-urlencoded');
                            res.setHeader('Access-Control-Allow-Origin', '*');
                            res.status(200).send(result);
                        }
                    }
                );

                request.addParameter('requestMessageId', TYPES.NVarChar, requestMessageId);

                request.on('row', function(columns) {
                    var row = {};

                    columns.forEach(function(column) {
                        if (column.value === null) {
                            console.log('NULL');
                        } else {
                            row[column.metadata.colName] = column.value;
                        }
                    });

                    result.push(row);
                });

                request.on('done', function(rowCount, more) {
                    console.log(rowCount + ' rows returned');
                });

                connection.execSql(request);
            }
        });
开发者ID:MattGauler,项目名称:support-portal-uat,代码行数:54,代码来源:supportResponse.ts

示例6: function

                bcrypt.hash(password, 8, function(err, hash) {
                    if(!err) {
                        var request = new Request(
                            '[dbo].[CreateNewUser]',
                            function(err, rowCount) {
                                console.log('RC: ' + rowCount)
                                if (err) {
                                    console.log(err);
                                    res.status(500).send();
                                }
                                else {
                                    connection.close();
                                    res.status(200).send();
                                }
                            }
                        )

                        request.addParameter('UserId', TYPES.NVarChar, username);
                        request.addParameter('Password', TYPES.NVarChar, hash);
                        request.addParameter('Depot', TYPES.NVarChar, depot);
                        request.addParameter('CreatedOn', TYPES.DateTime, new Date());
                        request.addParameter('ApiKey', TYPES.NVarChar, Guid.raw());
                        request.addParameter('ServerKey', TYPES.NVarChar, Guid.raw());
                        request.addParameter('CreateUsers', TYPES.Bit, createUsers)

                        connection.callProcedure(request);
                    }
                });
开发者ID:MattGauler,项目名称:support-portal-uat,代码行数:28,代码来源:createUser.ts

示例7: function

        managers.dbManager.allowRequest(userId, apiKey, function(authorised) {
            if(!authorised) {
                res.status(500).send();
            }
            else {
                var result = [];

                var request = new Request(
                    `
                        Select
                            delaybandId as ID,
                            delayBandLabel as [Band],
                            0 as [Occurences]
                        from
                           responseDelayBands 
                    `,
                    function(err, rowCount) {
                        if (err) {
                            console.log(err);
                            res.status(500).send("Error");
                        }
                        else {
                            console.log('Complete: %s row(s) returned', rowCount);
                            connection.close();
                            res.send(result);
                        }
                    }
                );

                request.on('row', function(columns) {
                    var row = {};

                    columns.forEach(function(column) {
                        if (column.value === null) {
                            console.log('NULL');
                        } else {
                            row[column.metadata.colName] = column.value;
                        }
                    });

                    result.push(row);
                });

                request.on('done', function(rowCount, more) {
                    console.log(rowCount + ' rows returned');
                });

                connection.execSql(request);
            }
        });
开发者ID:MattGauler,项目名称:support-portal-uat,代码行数:50,代码来源:connectivityDelayBands.ts

示例8: function

        managers.dbManager.allowRequest(userId, apiKey, function(authorised) {
            if(!authorised) {
                res.status(500).send();
            }
            else {
                var result = [];

                var request = new Request(
                    `
                        SELECT CD.Id, CD.DeviceId, CD.UserId, CD.RouteId, CD.LastConnected, PD.IsPilot
                        FROM dbo.ConnectedDevices CD
                        LEFT JOIN [dbo].[PilotDevices] PD ON CD.DeviceId = PD.DeviceId
                        WHERE CD.LastConnected > CAST(GETDATE() AS DATE);
                    `,
                    function(err, rowCount) {
                        if (err) {
                            console.log(err);
                            res.status(500).send("Error");
                        }
                        else {
                            console.log('Complete: %s row(s) returned', rowCount);
                            connection.close();
                            res.setHeader('content-type', 'application/x-www-form-urlencoded');
                            res.setHeader('Access-Control-Allow-Origin', '*');
                            res.status(200).send(result);
                        }
                    }
                );

                request.on('row', function(columns) {
                    var row = {};

                    columns.forEach(function(column) {
                        if (column.value === null) {
                            console.log('NULL');
                        } else {
                            row[column.metadata.colName] = column.value;
                        }
                    });

                    result.push(row);
                });

                request.on('done', function(rowCount, more) {
                    console.log(rowCount + ' rows returned');
                });

                connection.execSql(request);
            }
        });
开发者ID:MattGauler,项目名称:support-portal-uat,代码行数:50,代码来源:connectedDevices.ts

示例9: Date

        this.pool.acquire(function (err, connection) {
            if (err)
                console.error(err);

            var request = new tedious.Request('dbo.createConnectionRequest',function(err, rowCount){
                connection.release();    
            });
               
            var TYPES = tedious.TYPES;

            request.addParameter('MessageID', TYPES.NVarChar, message.id);
            request.addParameter('RequestSent', TYPES.DateTime, new Date(message.date));
            
            connection.callProcedure(request);      
        });
开发者ID:MattGauler,项目名称:support-portal-uat,代码行数:15,代码来源:dbManager.ts


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