6
這種模式使我在重複數據和一般uglyness犧牲我想要的效果:Sails.js複合材料獨特的領域
//Example
var Example = {
attributes: {
foo: {
type: 'string',
required: true
},
bar: {
type: 'string',
required: true,
},
baz: {
type: 'integer',
required: true,
min: 1
},
foobar: {
type: 'string',
unique: true
}
},
beforeValidation : function(values,cb) {
values.foobar = values.foo+values.bar;
cb();
}
};
module.exports = Example;
有用於創建一個複合唯一鍵更好的策略?
我也在尋找這個問題的答案,但在水線。你有沒有使用這種技術,併爲你工作?還是你使用了特定於數據庫的解決方案(不是我想要追求的)? – Charlie