website icon indicating copy to clipboard operation
website copied to clipboard

How to use HasManyAddAssociationMixin when Typescript uses ModelDefine definition

Open MrChen2016-08-27 opened this issue 4 years ago • 4 comments

Regarding the use of ModelDefine in the document, how should I add a statement to Note through HasManyAddAssociationMixin to prevent Typescript checking errors:

image

MrChen2016-08-27 avatar Aug 12 '21 10:08 MrChen2016-08-27

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

github-actions[bot] avatar Oct 27 '21 18:10 github-actions[bot]

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

github-actions[bot] avatar Nov 04 '21 00:11 github-actions[bot]

Have you tried the following?

const Node: ModelDefined<NoteAttributes, NoteCreationAttributes> & {
  // extra types here
  addSomething: HasManyAddAssociationMixin
} = sequelize.define(...)

ephys avatar Jan 06 '22 17:01 ephys

I'm having this same question. Adding the declare setSomething: HasManySetAssociationsMixin<Model, primaryKeyType> only works when I create data in the repository, if I try to create the data in the service layer, it says that setSomething does not exist on type ModelOutputAttributes.

How to implement it correctly?

Jeferson-Emanuel avatar Jul 28 '22 15:07 Jeferson-Emanuel