我在查询数据库时,定义的模板是:
module.exports = function(sequelize,Sequelize){
var User = sequelize.define('userinfo',{
id:{
type: Sequelize.FLOAT,
primaryKey: true
},
name:{
type:Sequelize.STRING
} ,
password :{
type: Sequelize.STRING
},
email :{
type: Sequelize.STRING
} ,
phone :{
type: Sequelize.STRING
},
qq :{
type: Sequelize.STRING
},
ifmanager:{
type: Sequelize.BOOLEAN
}
});
return User;
}
然后进行调用:
var User = require('./module/userinfo')(sequelize,Sequelize);
var result = yield User.findAll({
attributes:['password'],
where:{
name:name
}
});
console.log(result);
但最终控制台打印出的MYSQL语句是
SELECT password
FROM userinfos
AS userinfos
WHERE userinfos
.name
= 'jession'
请问userinfos是怎么来的?
In fact, the real table name can be set in the defined model. The third parameter of sequelize.define is a json object, in which the tableName can be set. For specific usage, please refer to the official sequelize documentation