UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

43 lines (35 loc) 1.27 kB
// 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) }; // tslint:disable-next-line:max-func-body-length async function main() { await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false }); const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection); const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection); let result = await transactionRepo.countPotentiallyExportTasks({ endDate: { $lt: moment() // tslint:disable-next-line:no-magic-numbers .add(-60, 'seconds') .toDate() }, limit: 10 }); console.log('result', result); result = await taskRepo.countPotentiallyRunning({ runsAt: { $lt: moment() // tslint:disable-next-line:no-magic-numbers .add(-60, 'seconds') .toDate() }, name: { $eq: chevre.factory.taskName.DeleteTransaction }, limit: 10 }); console.log('result', result); } main() .then() .catch(console.error);