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

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

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

    const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
    const result = await transactionRepo.startExportTasks({
        // typeOf: { $in: [chevre.factory.transactionType.PlaceOrder] },
        status: { $eq: chevre.factory.transactionStatusType.Confirmed },
        tasksExportAction: { agent: { name: 'xxx' } },
        endDate: { $lt: new Date() }
    });
    console.log(result);
}

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