从SailsJS使用水线ORM,我对违约autoCreatedAt和autoUpdatedAt被设置为false,但我仍然需要实现的功能只是用不同的字段名(DBA请求).有没有办法:
created_ts并updated_ts在数据库模式本身中使用触发器进行更新(但我仍然需要Waterline来读取它们)?提前致谢.
Waterline文档提供了使用beforeCreate哈希密码的示例.除非您在密码字段上进行验证并尝试更新记录,否则这很有效.这是我的剪辑示例:
types: {
hasUpperCase: function (value) {
return value.search(/[A-Z]/) != -1;
},
hasLowerCase: function (value) {
return value.search(/[a-z]/) != -1;
},
hasNumber: function (value) {
return value.search(/[0-9]/) != -1;
}
},
attributes: {
password: {
type: 'string',
minLength: 8,
hasUpperCase: true,
hasLowerCase: true,
hasNumber: true
},
salt: {
type: 'string'
},
// ...
}
beforeCreate: function (values, next) {
// Encrypt the password and record the salt.
psalty.createHash(values.password)
.then(function (psalt) {
values.password = psalt.hash;
values.salt = psalt.salt;
next(); …Run Code Online (Sandbox Code Playgroud) 我正在为模型服务提供者构建测试计划,我想在测试之前加载测试数据(仅使用内存适配器)(相对简单),但是在每个测试套件之后有一种快速而又脏的方法来截断所有集合完了吗?
提前致谢.