Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

node.js - Mikro ORM: properties are having any type on orm.em.create();

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()

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...