Model.create({value1: ""}) fails because $add, $set, $get, $count, and 32 more properties are missing.
The instance of the model is created with the specified values.
Open the related code-repository, open the lib/routes/actors.ts file, it should show a type error.
https://github.com/sleiss/sequelize-typescript-example
lib/routes/actors.ts (8,38): Argument of type '{ firstName: string; lastName: string; }' is not assignable to parameter of type 'Actor'.
Type '{ firstName: string; lastName: string; }' is missing the following properties from type 'Actor': $add, $set, $get, $count, and 32 more. (2345)
same problem. my solution is:
const application = await this.applicationRepository.create<Application>(
({
id: Math.random().toString(32),
createdAt: new Date(),
updatedAt: new Date(),
...createApplicationDto,
} as any) as Application,
{ transaction },
);
but this cannot utilizes typescript features anymore. hope someone can give a better solution.
I met the same problem, do you have a better plan?
same here
@sleiss, you probably want to declare models like this: https://github.com/RobinBuschmann/sequelize-typescript#model-definition
your example code is using export class Actor extends Model<Actor>, which is definition for sequelize v5 & sequelize-ts v1.
@lukashroch This indeed seems to fix the issue.
I'll validate it now.
@lukashroch Thanks, it fixed the issue.
Most helpful comment
@sleiss, you probably want to declare models like this: https://github.com/RobinBuschmann/sequelize-typescript#model-definition
your example code is using
export class Actor extends Model<Actor>, which is definition for sequelize v5 & sequelize-ts v1.