All files / src/domains/projects/schemas task.schema.ts

0% Statements 0/27
0% Branches 0/42
100% Functions 0/0
0% Lines 0/25

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                                                                                                     
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ collection: 'tasks', timestamps: true })
export class Task extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  projectId!: MongooseSchema.Types.ObjectId;
  @Prop({ required: true }) taskCode!: string;
  @Prop({ required: true }) title!: string;
  @Prop() description?: string;
  @Prop({
    required: true,
    enum: ['feature', 'bug', 'enhancement', 'epic', 'subtask'],
  })
  type!: string;
  @Prop({
    required: true,
    enum: ['todo', 'in_progress', 'in_review', 'done', 'cancelled'],
  })
  status!: string;
  @Prop({ required: true, enum: ['low', 'medium', 'high', 'highest'] })
  priority!: string;
 
  @Prop({ type: MongooseSchema.Types.ObjectId })
  assigneeId?: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  reporterId?: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  milestoneId?: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  parentTaskId?: MongooseSchema.Types.ObjectId;
 
  @Prop() startDate?: Date;
  @Prop() dueDate?: Date;
  @Prop({ default: 0 }) estimatedHours!: number;
  @Prop({ default: 0 }) loggedHours!: number;
  @Prop({ default: 0 }) storyPoints!: number;
 
  @Prop({ type: MongooseSchema.Types.Mixed }) recurrenceRule?: Record<
    string,
    unknown
  >;
  @Prop({ type: [MongooseSchema.Types.Mixed], default: [] })
  checklists!: Record<string, unknown>[];
  @Prop({ type: [String], default: [] }) tags!: string[];
}
export const TaskSchema = SchemaFactory.createForClass(Task);
TaskSchema.index({ tenantId: 1, projectId: 1, taskCode: 1 }, { unique: true });