import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Types, Document } from 'mongoose'; import { ObjectType, Field, ID } from '@nestjs/graphql'; import { Base } from '@/models/base.model'; @ObjectType() @Schema({ timestamps: true }) export class BuildSites extends Base { @Field(() => ID) readonly _id: string; @Field(() => String) @Prop({ required: true }) siteName: string; @Field(() => String) @Prop({ required: true }) siteNo: string; @Field(() => ID, { nullable: true }) @Prop({ type: Types.ObjectId, ref: 'BuildAddress', required: false }) address?: Types.ObjectId; } export type BuildSiteDocument = BuildSites & Document; export const BuildSiteSchema = SchemaFactory.createForClass(BuildSites);