const db = require('../db');
const xlsx = require('node-xlsx').default;
const fs = require('fs');
const _ = require('lodash');
const moment = require('moment');
async function task(argument) {
  const bill = await db.getCollection('bills');
  const bills = await bill.find({ endDate: { $exists:false } ,pre:false}).toArray();
  console.dir(bills.length);
  bills.forEach( async ({ createdAt, date, _id }) => {
    let endDate = moment(createdAt).format('YYYYMMDD');
    let endTime = parseInt(moment(createdAt).format('x'));
    let endAt = createdAt;
    //await bill.update({ _id },{ "$set": { endDate, endAt, endTime}});
    let rep = await bill.update({ _id },{ "$set": { endDate, endAt, endTime}});
    console.dir(rep)
  });
}



task();


