royib / clean-architecture-nestJS

An in-depth implementation of Clean Architecture using NestJS and type-script
795 stars 192 forks source link

is it possible to merge #11

Open MaxLiu0325 opened 1 year ago

MaxLiu0325 commented 1 year ago

Hi, I have some questions src/core/entities/book.entity.ts

and

src/frameworks/data-services/mongo/model/book.model.ts

Is it possible to merge?

If use typeorm don't need implement IGenericRepository?

thanks

gvozdenkov commented 3 months ago

@royib Yep, duplicated fields not looks good...

// books.entity.ts
export class Book {

  title: string;

  author: Author;

  genre: Genre;

  publishDate: Date;
}
// mongo schema with the same fields
@Schema()
export class Book {
  @Prop({ required: true, unique: true })
  title: string;

  @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'Author', required: true })
  author: Author;

  @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'Genre', required: true })
  genre: Genre;

  @Prop()
  publishDate: Date;
}