Sequelize.js 为什么要向结果集中添加额外的属性
我使用的是Sequelize Mock,基于我的模型,我没想到会有Sequelize.js 为什么要向结果集中添加额外的属性,sequelize.js,Sequelize.js,我使用的是Sequelize Mock,基于我的模型,我没想到会有id属性或时间戳有没有办法抑制它们 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 mode
id属性或时间戳
有没有办法抑制它们
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.jsconsole.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: false
要防止创建主键id
,请将任何其他列设置为主键,如
Property1: {
type: Sequelize.STRING,
primaryKey: true
}
您可以关闭时间戳(尽管您可能不应该)。我怀疑你能关掉身份证。在
sequelize mock
中,如何准确设置主键?第一个参数用于默认值,第二个参数用于配置。