2023-10-31 09:03:41 +03:00
|
|
|
import { Schema, model } from "mongoose";
|
2023-11-20 00:48:40 +03:00
|
|
|
import { PipelineValidationModel, schemaPipeline } from "../pipelines/pipeline_model";
|
|
|
|
import { IsArray, IsString } from "class-validator";
|
2023-10-27 21:22:48 +03:00
|
|
|
|
|
|
|
export interface IProjectModel {
|
2023-11-20 00:48:40 +03:00
|
|
|
_id?: string;
|
|
|
|
pipelines: [PipelineValidationModel];
|
2023-10-27 21:22:48 +03:00
|
|
|
rootDir: string;
|
2023-11-10 12:06:40 +03:00
|
|
|
description: string;
|
2023-11-20 00:48:40 +03:00
|
|
|
isActive:boolean;
|
2023-10-27 21:22:48 +03:00
|
|
|
}
|
2023-10-26 17:44:54 +03:00
|
|
|
|
|
|
|
export const ProjectSchema = new Schema({
|
2023-10-27 21:22:48 +03:00
|
|
|
pipelines: {
|
|
|
|
type: Array<Schema.Types.ObjectId>,
|
|
|
|
ref: schemaPipeline,
|
|
|
|
autopopulate: true,
|
|
|
|
default: null,
|
|
|
|
},
|
2023-11-10 12:06:40 +03:00
|
|
|
description: {
|
|
|
|
type: String,
|
|
|
|
},
|
2023-11-20 00:48:40 +03:00
|
|
|
isActive: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2023-10-27 21:22:48 +03:00
|
|
|
}).plugin(require("mongoose-autopopulate"));
|
2023-10-26 17:44:54 +03:00
|
|
|
|
2023-11-20 00:48:40 +03:00
|
|
|
export const projectSchema = "Projects";
|
2023-10-26 17:44:54 +03:00
|
|
|
|
2023-11-20 00:48:40 +03:00
|
|
|
export const ProjectDBModel = model<IProjectModel>(projectSchema, ProjectSchema);
|
2023-10-26 17:44:54 +03:00
|
|
|
|
2023-11-14 20:44:06 +03:00
|
|
|
export class ProjectValidationModel {
|
|
|
|
@IsArray()
|
|
|
|
public pipelines: [string];
|
2023-11-10 12:06:40 +03:00
|
|
|
@IsString()
|
|
|
|
public description: string;
|
2023-11-20 00:48:40 +03:00
|
|
|
|
2023-10-27 21:22:48 +03:00
|
|
|
}
|