import { model, Schema } from 'mongoose';
const workItemSchema = new Schema({
    id: { type: Number, required: true },
    collectionName: { type: String, required: true },
    project: { type: String, required: true },
    workItemType: { type: String, required: true },
    state: { type: String, required: true },
    changeDate: { type: Date, required: true },
    createdDate: { type: Date, required: true },
    title: { type: String, required: true },
    description: { type: String, required: true },
    closedDate: Date,
    stateChangeDate: Date,
    priority: Number,
    severity: String,
    fields: Schema.Types.Mixed,
    url: String,
    relations: [
        {
            rel: String,
            url: String,
            attributes: Schema.Types.Mixed,
        },
    ],
});
workItemSchema.index({ collectionName: 1, id: 1 }, { unique: true }); // Used for writes
workItemSchema.index({
    collectionName: 1,
    project: 1,
    workItemType: 1,
    state: 1,
});
workItemSchema.index({
    collectionName: 1,
    project: 1,
    stateChangeDate: 1,
});
export const WorkItemModel = model('WorkItem', workItemSchema);
