问题
How can I enforce a Model property to be exactly 32 characters long?
I have tried
key : {
type: 'string',
len : 32
}
but it doesn't work.
回答1:
Ok, let me tell you what i did.
After reading hours y figure out that "columnType" property is the solution. It works together with "type" property. For example. I have a "description" field. It looks like:
descripcion: { type: 'string', columnType: 'varchar (27)' }
And it works. (this is for mysql db).
I hope this works for you. This is on the docs. Model verbatim field
回答2:
Apparently the correct way to do it is:
maxLength : 32,
minLength : 32,
来源:https://stackoverflow.com/questions/26412704/string-of-certain-length-in-sailsjs-model