import { Schema, Document } from 'mongoose' import db from '../service/db' import * as _ from 'lodash' export interface IUTaskflowstatusModel extends Document { _id: string name: string } const taskflowstatus = new Schema({ name: { type: String, required: true, es_indexed: true, maxlength: 100 }, pos: { type: Number, default: 0, set(val) { return _.toInteger(val) }, get(val) { return _.toInteger(val) } }, _taskflowId: { type: Schema.Types.ObjectId, ref: 'Taskflow', required: true }, rejectStatusIds: [ { type: Schema.Types.ObjectId, ref: 'Taskflowstatus' } ], kind: { type: String, required: true, default: 'start', enum: ['start', 'end', 'unset'] }, _creatorId: { type: Schema.Types.ObjectId, ref: 'User', required: true }, isDeleted: { type: Boolean, es_indexed: true, default: false }, created: { type: Date, default: Date.now, es_indexed: true }, updated: { type: Date, default: Date.now, es_indexed: true } }) export const TaskflowstatusModel = db.model('Taskflowstatus', taskflowstatus)