Postgres 方言在 sequelize 中不起作用
Postgres dialect is not working in sequelize
运行 我的 Express 项目在装有 pgAdmin4 的 Windows 10 机器上。
在 sequelize/config.json
带有 postgres 方言 的文件中,Sequelize 给出了一些错误。
"development": {
"username": "root",
"password": null,
"database": "database_development",
"host": "127.0.0.1",
"port": "5432",
"dialect": "postgres"
}
但是使用 sqlite 方言,它工作正常。
"development": {
"dialect": "sqlite",
"storage": "./db.development.sqlite"
}
运行 gulp watch
使用 postgres 方言,出现以下错误:
$ gulp watch
[22:00:43] Using gulpfile ~\friendly-stuff\gulpfile.js
[22:00:43] Starting 'build'...
[22:00:43] Starting 'clean'...
[22:00:43] Finished 'clean' after 28 ms
[22:00:43] Starting 'stylus'...
[22:00:43] Finished 'stylus' after 101 ms
[22:00:43] Finished 'build' after 132 ms
[22:00:43] Starting 'server:start'...
[22:00:43] Finished 'server:start' after 10 ms
[22:00:43] Starting 'watch'...
[22:00:43] Finished 'watch' after 20 ms
[22:00:44] Development server listening. (PID:12632)
Mon, 19 Sep 2016 02:00:44 GMT friendly-stuff:server Listening on port 3000
Unhandled rejection SequelizeConnectionRefusedError:
connect ECONNREFUSED 127.0.0.1:5432 at
C:\Users\user1\MyProj\node_modules\sequelize\lib\dialects\
postgres\connection-manager.js:98:20 at Connection.
我认为还有一些其他配置需要添加或更改。但我不确定是哪一个。您认为我正在使用的 widows/pgadmin 版本是否导致了其中一些错误或 windows 10 firewall/security 阻塞了端口?
确保:
1) Postgres db is running
2) pg is installed:
npm install --save pg
3) Add also protocol to your config
'dialect':'postgres',
'protocol':'postgres'
运行 我的 Express 项目在装有 pgAdmin4 的 Windows 10 机器上。
在 sequelize/config.json
带有 postgres 方言 的文件中,Sequelize 给出了一些错误。
"development": {
"username": "root",
"password": null,
"database": "database_development",
"host": "127.0.0.1",
"port": "5432",
"dialect": "postgres"
}
但是使用 sqlite 方言,它工作正常。
"development": {
"dialect": "sqlite",
"storage": "./db.development.sqlite"
}
运行 gulp watch
使用 postgres 方言,出现以下错误:
$ gulp watch
[22:00:43] Using gulpfile ~\friendly-stuff\gulpfile.js
[22:00:43] Starting 'build'...
[22:00:43] Starting 'clean'...
[22:00:43] Finished 'clean' after 28 ms
[22:00:43] Starting 'stylus'...
[22:00:43] Finished 'stylus' after 101 ms
[22:00:43] Finished 'build' after 132 ms
[22:00:43] Starting 'server:start'...
[22:00:43] Finished 'server:start' after 10 ms
[22:00:43] Starting 'watch'...
[22:00:43] Finished 'watch' after 20 ms
[22:00:44] Development server listening. (PID:12632)
Mon, 19 Sep 2016 02:00:44 GMT friendly-stuff:server Listening on port 3000
Unhandled rejection SequelizeConnectionRefusedError:
connect ECONNREFUSED 127.0.0.1:5432 at
C:\Users\user1\MyProj\node_modules\sequelize\lib\dialects\
postgres\connection-manager.js:98:20 at Connection.
我认为还有一些其他配置需要添加或更改。但我不确定是哪一个。您认为我正在使用的 widows/pgadmin 版本是否导致了其中一些错误或 windows 10 firewall/security 阻塞了端口?
确保:
1) Postgres db is running
2) pg is installed:
npm install --save pg
3) Add also protocol to your config
'dialect':'postgres', 'protocol':'postgres'