G
G
greendev2021-07-12 22:00:35
typescript
greendev, 2021-07-12 22:00:35

What type to specify at Model?

I use sequelize.
Pulling data from the database:
const user = await User.findOne({where: {username}});

But if you turn to user.id or user.username, then typescript swears that there is no such data in the Model.
How can I enter this data or extend the Model?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Shvedov, 2021-07-12
@greendev

I advise you to take the sequelize-typescript package , where in the dock it is immediately described how to declare your model and expand it with your fields, and all this with the help of classes and decorators

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question