ctx.model.extend中如何定义字段的default属性?

  ctx.model.extend('blacklist_manager', {
    id: { type: 'unsigned', nullable: false },
    aid: { type: 'unsigned', length: 20, nullable: false },
    userId: { type: 'string', length: 100, nullable: false },
    userName: { type: 'string', length: 255, nullable: false },
    createdAt: { type: 'timestamp', nullable: false,default: 'CURRENT_TIMESTAMP' },
    operator: { type: 'string', length: 255 }
  }, {
    primary: 'id',
    autoInc: true,
    unique: [['aid']]
  })

这是我定义的表结构,在构建的时候报错没有default这个属性:

1 个赞

使用 initial 才对,你从什么地方看到的 default?


数据模型 | Koishi

2 个赞

deepseek说的 :joy:谢谢

4 个赞