I'm getting this error Property 'pwd' does not exist on type 'Model<any, any>' even when the model is defined as Model<Attribs, OptionalAttribs>, below give is the snippet
model def
import {Optional, ModelAttributes , STRING, UUID, DataTypes } from 'sequelize'
import { Table, Model } from 'sequelize-typescript'
export type Attribs = Required<IAppUser>
export type OptionalAttribs = Optional<IAppUser, 'id'>
@Table
class AppUser extends Model<Attribs, OptionalAttribs> {
public pwd!: string
}
export const AppUserAttributes = {
id: {
type: UUID,
defaultValue: DataTypes.UUIDV4,
allowNull: false
}
pwd: {
type: STRING,
allowNull: false
}
}
import { Sequelize } from 'sequelize-typescript'
sequelize.addModels([AppUser, Algo])
AppUser.init(AppUserAttributes, {sequelize})
AppUser.sync({ force: true })
usage
const page = req.params.page ? req.params.page : 1;
const limit = req.params.limit ? req.params.limit : 10;
const appUsers = await AppUser.findAll({
limit: limit,
offset: (page - 1) * limit,
order: [['id', 'DESC']],
});
appUsers?.forEach((appUser) => {
console.log(appUser)
appUser.pwd = '******'
})
package.json
"sequelize": "^6.12.2",
"sequelize-typescript": "^2.1.1",
```
its not able to identify appUser as type of Model<Attribs, OptionalAttribs> rather it takes as Model<any,any>
any pointers why?
the code is @ https://github.com/arunsoman/mintit