最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I set a default value using enum type in column Mysql using Knex.js? - Stack Overflow

programmeradmin3浏览0评论

I am using AdonisJS to make a backend application. In migrations, specifically in models, we have the option of creating models, but I can't use a default value in enun type. After reading the Knex.js documentation, I couldn't find a way to put this default value in enum type (table.enu) in SGDB Mysql. Could anyone help?

.1/migrations

I am using AdonisJS to make a backend application. In migrations, specifically in models, we have the option of creating models, but I can't use a default value in enun type. After reading the Knex.js documentation, I couldn't find a way to put this default value in enum type (table.enu) in SGDB Mysql. Could anyone help?

https://adonisjs./docs/4.1/migrations

http://knexjs/#Schema-enum

Share Improve this question asked Sep 23, 2019 at 15:27 Taffarel XavierTaffarel Xavier 5328 silver badges13 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 14

Did you try defaultTo() :

defaultTo — column.defaultTo(value)

Sets the default value for the column on an insert.

From knex Documentation

Example :

table.enu('role', ['one', 'two', 'three']).defaultTo('two', options={})

Adonis Enu/Enum documentation

Adonis defaultTo documentation

发布评论

评论列表(0)

  1. 暂无评论