Created
January 19, 2022 15:41
-
-
Save royib/2c529724a69419266774cdeb20bdece1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
import * as mongoose from 'mongoose'; | |
import { Author, Genre } from './'; | |
export type BookDocument = Book & Document; | |
@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; | |
} | |
export const BookSchema = SchemaFactory.createForClass(Book); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment