String of certain length in Sailsjs Model

放肆的年华 提交于 2019-12-22 14:55:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!