我正在使用 Sequelize-Mock 并且基于我的模型,我没想到会有 id property or timestamps
有没有办法抑制这些?
mock.js
var UserMock = DBConnectionMock.define('users', {
'Property1': 5,
'Property2': 10,
'Property3': 15,
'Property4': 25
})
// From there we can start using it like a normal model
exports.getTotals = () => {
return UserMock.findAll().then(r => r);
}
index.js console.log 结果
[[ { Property1: 5,
Property2: 10,
Property3: 15,
Property4: 25,
id: 1,
createdAt: '2018-07-28T03:54:14.442Z',
updatedAt: '2018-07-28T03:54:14.442Z' } ]]
最佳答案
要禁用 timeStamps
集,
timestamps: false
为了防止创建主键
id
,请将任何其他列设置为主键,例如,Property1: {
type: Sequelize.STRING,
primaryKey: true
}
关于sequelize.js - 为什么将额外的属性添加到结果集中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51567911/