I am have created a product entity, and using the ORM to generate fake data. But however, the em.create is using any as the type of entity's properties. Also, em.create has made all properties optional including the ones which I explicitly set to be required with !
mark (Product.name
for eg). I cannot see what am I doing wrong. Here's the code
Product Entity:
@Entity()
export class Product {
@PrimaryKey()
_id!: ObjectId;
@SerializedPrimaryKey()
id!: string;
@Property()
name!: string;
@Property()
createdAt: Date = new Date();
@Property({ onUpdate: () => new Date() })
updatedAt: Date = new Date();
@Property()
description!: string;
@Property()
image!: string;
@Property()
price!: number;
@Property()
tags: string[] = [];
@Property()
quantity: number = 0;
}
The types by em.create()
Please let me know what I am doing wrong?
question from:
https://stackoverflow.com/questions/65862509/mikro-orm-properties-are-having-any-type-on-orm-em-create 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…