require("dotenv").config(); const mongoose = require('mongoose'); const wolfcount = require('../models/wolfcount'); const moment = require('moment'); const uri = `mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority` mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => { console.log(''); console.log(`Connected to the database`); }).catch((error) => { console.log(`Failed to connect to the database`); console.log(error); }); console.log(`${moment(Date.now()).format('DD/MM/YY H:mm:ss')} Starting count refresh...`); // Find a document by validation wolfcount.findOne({ validation: 'wolfcount' }).then((countdocument) => { console.log(''); //console.log(countdocument); console.log(`Refreshed count`) const basecount = countdocument.count console.log(''); }).catch((error) => { console.error(error); }); console.log(`${moment(Date.now()).format('DD/MM/YY H:mm:ss')} Refreshed wolfcount on cron`);