sequelize-auto icon indicating copy to clipboard operation
sequelize-auto copied to clipboard

a bug when generate Attributes

Open li-qs opened this issue 3 years ago • 1 comments

I think there might be a bug here: sequelize-auto/src/auto-generator.ts line 103.

With TypeScript, when using find method such as

MyModel.findOne({ where: { username: "user1" } })

IDE always prompts like this:

Type '{ username: string; }' is missing the following properties from type 'WhereAttributeHash<MyModelAttributes>': id, passwd, create_time ...

Because MyModelAttributes are not optional:

export interface MyModelAttributes {
  id: number
  username: string
  passwd: number
  create_time: Date
  // more...
}

So I think optional attributes should always be generated there.

li-qs avatar Feb 07 '22 13:02 li-qs

An issue for reference: https://github.com/sequelize/sequelize/issues/12716

li-qs avatar Feb 07 '22 13:02 li-qs