如何为Sequelize应用程序设置应用程序名称 [英] How to set the Application Name for a Sequelize application
问题描述
我有一个使用Sequelize作为ORM的nodejs应用程序.我已经成功地将Sequelize连接到数据库,但是在文档中没有找到任何说明如何设置应用程序名称的内容.为了明确起见,我正在为我的应用程序的连接字符串设置唯一的应用程序名称"属性.这样,当DBA查看流量时,他们便可以从其余信息中挑选出我应用程序的查询.
I've got a nodejs application that uses Sequelize as it's ORM. I've successfully got Sequelize connected to the database, but I haven't found anything in the documentation that explains how to set the application name. To clarify I'm looking to set a unique Application Name attribute for my app's connection string. That way when a DBA is looking at traffic they can pick out my application's queries from the rest.
Sequelize还能做到吗?还是需要在乏味的级别上完成?失败了,nodejs中是否可以指定连接字符串属性?
Is this something that Sequelize can even do? Or does this need to be done at the tedious level? Failing that, is there a way in nodejs to specify connection string attributes?
推荐答案
Tedious允许使用appName
配置参数设置应用程序名称.创建Sequelize连接时,应该可以通过dialectOptions
对象进行设置:
Tedious allows setting the app name with the appName
config param. You should be able to set this via the dialectOptions
object when creating your Sequelize connection:
var conn = new Sequelize('my_db', 'my_user', 'my_pass', {
host: 'my_server',
dialect: 'mssql',
dialectOptions: {
appName: 'my_app_name'
}
});
这篇关于如何为Sequelize应用程序设置应用程序名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!