Sails.js complex unique field

This model gives me the effect that I want due to duplicate data and general ugliness:

//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; 

Is there a better strategy for creating a composite unique key?

+6
source share
1 answer

It is not possible to do this right in the sails, see https://github.com/balderdashy/waterline/issues/221 . The best solution is to do this directly in the db that you plan to use.

+6
source

Source: https://habr.com/ru/post/972743/


All Articles