import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import mongoose, { HydratedDocument } from 'mongoose'; import { IAuthor } from '../interfaces/author.interface'; @Schema({ _id: false }) export class Author implements IAuthor { @Prop({ type: mongoose.Schema.Types.ObjectId, required: true }) userId: mongoose.Schema.Types.ObjectId; @Prop({ type: String, required: true }) fullName: string; @Prop({ type: String, required: false }) username?: string; } export const AuthorSchema = SchemaFactory.createForClass(Author); export type AuthorDocument = HydratedDocument;