import { Schema, model } from "mongoose"; import { IProjectModel, projectSchema } from "../projects/projects_model"; import { IsMongoId, IsOptional, IsString } from "class-validator"; export interface IProjectInstanceModel { project: IProjectModel; description: string; rootDir: string; isActive: boolean; } export const ProjectInstanceSchema = new Schema({ project: { type: Schema.Types.ObjectId, ref: projectSchema, autopopulate: true, default: null, }, description: { type: String, }, rootDir: { type: String, }, isActive: { type: Boolean, default: false, }, }).plugin(require("mongoose-autopopulate")); export const schemaProjectInstance = "instance_project"; export const ProjectInstanceDbModel = model( schemaProjectInstance, ProjectInstanceSchema ); export class ProjectInstanceValidationModel { @IsMongoId() public project: string; @IsString() public description: string; @IsOptional() public rootDir: string; }