webstudio/server/src/features/projects/projects_model.ts

40 lines
872 B
TypeScript
Raw Normal View History

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-10-31 09:03:41 +03:00
import { IsMongoId, IsString } from "class-validator";
2023-10-27 21:22:48 +03:00
export interface IProjectModel {
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-10-27 21:22:48 +03:00
export class ProjectModel implements IProjectModel {
2023-10-31 09:03:41 +03:00
@IsMongoId()
2023-11-10 12:06:40 +03:00
public pipelines: [PipelineModel];
2023-10-31 09:03:41 +03:00
@IsString()
2023-11-10 12:06:40 +03:00
public rootDir: string;
@IsString()
public description: string;
2023-10-27 21:22:48 +03:00
}