aboutsummaryrefslogtreecommitdiff
path: root/lib/event.schema.ts
blob: 664b5778f76563b2a82e8bdd4a8adc57bfce6a94 (plain)
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
import { Schema, Document } from 'mongoose';

export interface EventDocument<Context = any> extends Document {
  type: string;
  schedule: string;
  status?: 'notStarted' | 'running' | 'complete' | 'failed';
  error?: string;
  context: Context;
  nextRunAt?: Date;
  lastRunAt?: Date;
}

const schema = new Schema({
  type: {
    type: String,
    required: true
  },
  schedule: {
    type: String,
    required: true
  },
  status: {
    type: String,
    default: 'notStarted'
  },
  error: String,
  context: {},
  nextRunAt: Date,
  lastRunAt: Date
}, { timestamps: true });


export default schema;