And*_*die 11 node.js sails.js waterline
从SailsJS使用水线ORM,我对违约autoCreatedAt和autoUpdatedAt被设置为false,但我仍然需要实现的功能只是用不同的字段名(DBA请求).有没有办法:
created_ts并updated_ts在数据库模式本身中使用触发器进行更新(但我仍然需要Waterline来读取它们)?提前致谢.
Tri*_*eur 18
我刚开了两个拉请求来实现这个功能;
您也可以关注此问题.
通过此合并,在您的模型中,而不是例如:
autoCreatedAt: false,
autoUpdatedAt: false,
attributes: {
creationDate: {
columnName: 'created_ts',
type: 'datetime',
defaultsTo: function() {return new Date();}
},
updateDate: {
columnName: 'updated_ts',
type: 'datetime',
defaultsTo: function() {return new Date();}
}
},
beforeUpdate:function(values,next) {
values.updateDate = new Date();
next();
}
Run Code Online (Sandbox Code Playgroud)
你可以这样做:
autoCreatedAt: 'created_ts',
autoUpdatedAt: 'updated_ts'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3841 次 |
| 最近记录: |