我试图设置与MS SQL的连接但由于某种原因,sequelize无法正确传递主机名,而不是传递'localhost \ SQLEXPRESS'它传递'localhostSQLEXPRESS' . 知道在哪里解决它吗?
'use strict';
const _ = require('lodash');
var Sequelize = require('sequelize');
var sequelize = new Sequelize('mydb', 'db_user', 'db_user', {
host: 'localhost\SQLEXPRESS',
dialect: 'mssql',
pool: {
max: 5,
min: 0,
idle: 10000
},
});
// define model
var batchDetails = sequelize.define('batchDetails', {
id: {
type: Sequelize.STRING,
autoIncrement: true,
field:'id',
primaryKey: true
},
batch_no: {
type: Sequelize.STRING,
field:'batch_no',
},
date: {
type: Sequelize.DATE,
field:'date',
}
})
batchDetails.sync({force: true}).then(function () {
// Table created
return User.batchDetails({
id: 1,
batch_no: 'CASFR342'
});
});
错误日志: -
sequelize deprecated基于String的运算符现已弃用 . 请使用基于符号的运算符以获得更好的安全性,请参阅http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modules \ sequelize \ lib \ sequelize.js:242:13 tedious deprecated的默认值options.encrypt将从false更改为true . 如果要保留当前行为,请明确传递false . node_modules \ sequelize \ lib \ dialects \ mssql \ connection-manager.js:69:26未处理拒绝SequelizeHostNotFoundError:无法连接到localhostSQLEXPRESS:1433 - getaddrinfo ENOTFOUND localhostSQLEXPRESS at Connection.connection.on.err(C:\ Node JS Workspace \ db \ node_modules \ DB \ node_modules \ sequelize \ lib \ dialects \ mssql \ connection-manager.js:97:22)在Communication.emit(events.js:211:7)的emitOne(events.js:116:13)处at Connection.socketError(C:\ Node JS Workspace \ db \ node_modules \ DB \ node_modules \ tedious \ lib \ connection.js:1016:14)位于C:\ Node JS Workspace \ db \ node_modules \ DB \ node_modules \ tedious \ lib \ connection.js:861:25在GetAddrInfoReqWrap.callback(C:\ Node JS Workspace \ db \ node_modules \ DB \ node_modules \ tedious \ lib \ connector.js:69:18)的GetAddrInfoReqWrap.onlookupall [as oncomplete]( dns.js:104:17)