// tslint:disable:no-console
// import * as moment from 'moment';
import * as mongoose from 'mongoose';

import { chevre } from '../../../lib/index';

// const project = { id: String(process.env.PROJECT_ID) };

async function main() {
    await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });

    const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);

    const result = await taskRepo.deleteByName({
        name: <any>'orderProgramMembership',
        status: { $eq: chevre.factory.taskStatus.Ready }
        // runsAt: {
        //     $gte: moment('2023-05-20T00:00:00Z')
        //         .toDate(),
        //     $lte: moment('2023-12-20T00:00:00Z')
        //         .toDate()
        // }
    });

    console.log('deleted', result);
}

main()
    .then()
    .catch(console.error);
