UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

47 lines (40 loc) 1.6 kB
// tslint:disable:no-console import * as moment from 'moment'; import * as mongoose from 'mongoose'; import { chevre } from '../../../lib/index'; // tslint:disable-next-line:max-func-body-length async function main() { await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false }); const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection); const cursor = assetTransactionRepo.getCursor( { // typeOf: { $eq: chevre.factory.assetTransactionType.Pay }, status: { $eq: chevre.factory.transactionStatusType.Confirmed }, startDate: { // $lte: moment() // // tslint:disable-next-line:no-magic-numbers // .add(-28, 'days'), $gte: moment() // tslint:disable-next-line:no-magic-numbers .add(-180, 'days') } }, { } ); console.log('transactions found'); let i = 0; // tslint:disable-next-line:max-func-body-length await cursor.eachAsync(async (doc) => { i += 1; const reserveTransaction = <chevre.factory.assetTransaction.reserve.ITransaction>doc.toObject(); console.log( 'size:', JSON.stringify(reserveTransaction).length, reserveTransaction.typeOf, reserveTransaction.project.id, reserveTransaction.transactionNumber, reserveTransaction.startDate, i); }); console.log(i, 'transactions checked'); } main() .then() .catch(console.error);