How to set the Application Name for a Sequelize application

与世无争的帅哥 提交于 2020-01-03 18:58:55

问题


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.

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?


回答1:


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'
  }
});


来源:https://stackoverflow.com/questions/40404738/how-to-set-the-application-name-for-a-sequelize-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!