如何为 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屋!