2023-10-31 09:03:41 +03:00
|
|
|
import { Schema, model } from "mongoose";
|
2023-10-27 21:22:48 +03:00
|
|
|
import { PipelineModel, schemaPipeline } from "../pipelines/pipeline_model";
|
2023-11-14 20:44:06 +03:00
|
|
|
import { IsArray, IsOptional, IsString } from "class-validator";
|
2023-10-27 21:22:48 +03:00
|
|
|
|
|
|
|
export interface IProjectModel {
|
2023-11-16 00:40:35 +03:00
|
|
|
_id?:string;
|
2023-10-27 21:22:48 +03:00
|
|
|
pipelines: [PipelineModel];
|
|
|
|
rootDir: string;
|
2023-11-10 12:06:40 +03:00
|
|
|
description: string;
|
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,
|
|
|
|
},
|
|
|
|
rootDir: {
|
|
|
|
type: String,
|
|
|
|
},
|
2023-11-10 12:06:40 +03:00
|
|
|
description: {
|
|
|
|
type: String,
|
|
|
|
},
|
2023-10-27 21:22:48 +03:00
|
|
|
}).plugin(require("mongoose-autopopulate"));
|
2023-10-26 17:44:54 +03:00
|
|
|
|
|
|
|
const schema = "Projects";
|
|
|
|
|
|
|
|
export const ProjectDBModel = model<IProjectModel>(schema, ProjectSchema);
|
|
|
|
|
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-14 20:44:06 +03:00
|
|
|
@IsOptional()
|
|
|
|
public rootDir: string;
|
2023-10-27 21:22:48 +03:00
|
|
|
}
|