From 3187802430cd2d5b4d2dc50d3074d76503c88285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aar=C3=B3n=20P=C3=A9rez?= <50339331+AaronPerezPerez@users.noreply.github.com> Date: Thu, 15 Aug 2024 21:40:29 +0100 Subject: [PATCH 1/3] refactor: extends from BaseEntity to inherit the id property --- src/entities/Publisher.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/entities/Publisher.ts b/src/entities/Publisher.ts index 910b9e9..bd38d51 100644 --- a/src/entities/Publisher.ts +++ b/src/entities/Publisher.ts @@ -1,12 +1,9 @@ import { Collection, Entity, Enum, OneToMany, Opt, PrimaryKey, Property } from '@mikro-orm/core'; import { Book } from './Book'; +import { BaseEntity } from "./BaseEntity" @Entity() -export class Publisher { - - @PrimaryKey() - id!: number; - +export class Publisher extends BaseEntity { @Property() name: string; From df3280351f53ae16152ed05583c59589fdf3d88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ad=C3=A1mek?= Date: Wed, 29 Jan 2025 09:49:07 +0100 Subject: [PATCH 2/3] Apply suggestions from code review --- src/entities/Publisher.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/entities/Publisher.ts b/src/entities/Publisher.ts index bd38d51..685f059 100644 --- a/src/entities/Publisher.ts +++ b/src/entities/Publisher.ts @@ -1,9 +1,10 @@ import { Collection, Entity, Enum, OneToMany, Opt, PrimaryKey, Property } from '@mikro-orm/core'; import { Book } from './Book'; -import { BaseEntity } from "./BaseEntity" +import { BaseEntity } from './BaseEntity'; @Entity() export class Publisher extends BaseEntity { + @Property() name: string; From 1ade4e8ec311fc47375ffa31eccc06b7fc86a485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ad=C3=A1mek?= Date: Wed, 29 Jan 2025 09:51:51 +0100 Subject: [PATCH 3/3] fix tests --- src/entities/Publisher.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/entities/Publisher.ts b/src/entities/Publisher.ts index 685f059..ac9d0ef 100644 --- a/src/entities/Publisher.ts +++ b/src/entities/Publisher.ts @@ -15,6 +15,7 @@ export class Publisher extends BaseEntity { type: PublisherType & Opt; constructor(name: string, type = PublisherType.LOCAL) { + super(); this.name = name; this.type = type; }