1 import { values } from 'lodash'
2 import * as Sequelize from 'sequelize'
4 import { JOB_STATES } from '../initializers'
6 import { addMethodsToModel } from './utils'
13 } from './job-interface'
15 let Job: Sequelize.Model<JobInstance, JobAttributes>
16 let listWithLimit: JobMethods.ListWithLimit
18 export default function defineJob (sequelize: Sequelize.Sequelize, DataTypes) {
19 Job = sequelize.define<JobInstance, JobAttributes>('Job',
22 type: DataTypes.ENUM(values(JOB_STATES)),
26 type: DataTypes.STRING,
43 const classMethods = [ listWithLimit ]
44 addMethodsToModel(Job, classMethods)
49 // ---------------------------------------------------------------------------
51 listWithLimit = function (limit: number, state: string, callback: JobMethods.ListWithLimitCallback) {
62 return Job.findAll(query).asCallback(callback)