-
Notifications
You must be signed in to change notification settings - Fork 22
add ssl connection support #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vanoneang
vanoneang
approved these changes
Jun 13, 2019
欢迎大佬的PR,不过仔细看了一下,ssl的支持是有必要的,不过仅仅一个ssl的配置似乎还是不够灵活,究其根本,还是因为sequelize的init不够灵活。
所以,我们会更改sequelize的实例化的配置,大致的思路如下:
import { Sequelize } from 'sequelize'; import { config } from './config'; /** * 数据库配置项 */ /** * 数据库名,默认lin-cms */ const database = config.getItem('db.database', 'lin-cms'); /** * 数据库用户名,默认root */ const username = config.getItem('db.username', 'root'); /** * 数据库密码,默认123456 */ const password = config.getItem('db.password', '123456'); const options = config.getItem('db'); // 伪代码 // 排除掉不需要的三项配置 del(options,['password','username','database']); /** * 全局的 Sequelize 实例 */ export const db = new Sequelize(database, username, password, { ...options });
这样不仅可以支持ssl,还可以支持其它所有的sequelize配置。
当然,也有一个小缺点,那就是数据库的类型配置从type
变成了dialect
。
关于所有的sequelize初始化配置参考文档
希望你能仔细阅读,期待你的反馈
大佬的提议很好,不过sequelize文档有坑,建议按需求慢慢加
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.