text: // Import mongoose and models
  let mongoose = require('mongoose');
  let db = require('../models');
  
  // Configure environmental variables
  require('dotenv').config();
  
  // Local database connection
  const LOCALDB_URI = 'mongodb://localhost/workoutdb';
  
  // Connect to either deployed or local database to seed data
  mongoose.connect(process.env.MONGODB_URI || LOCALDB_URI,{
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useCreateIndex: true,
    useFindAndModify: false,
  });
  
  // Seed data array
  let workoutSeed = [
    {
      day: new Date(new Date().setDate(new Date().getDate() - 10)),
      exercises: [
        {
          type: 'resistance',
          name: 'Bicep Curl',
          duration: 20,
          weight: 100,
          reps: 10,
          sets: 4,
        },
      ],
    },
    {
      day: new Date(new Date().setDate(new Date().getDate() - 9)),
      exercises: [
        {
          type: 'resistance',
          name: 'Lateral Pull',
          duration: 20,
          weight: 300,
          reps: 10,
          sets: 4,
        },
      ],
    },
    {
      day: new Date(new Date().setDate(new Date().getDate() - 8)),
      exercises: [
        {
          type: 'resistance',
          name: 'Push Press',
          duration: 25,
          weight: 185,
          reps: 8,
          sets: 4,
        },
      ],
    },
    {
      day: new Date(new Date().setDate(new Date().getDate() - 7)),
      exercises: [
        {
          type: 'cardio',
          name: 'Running',
          duration: 25,
          distance: 4,
        },
      ],
    },
    {
      day: new Date(new Date().setDate(new Date().getDate() - 6)),
      exercises: [
        {
          type: 'resistance',
          name: 'Bench Press',
          duration: 20,
          weight: 285,
          reps: 10,
          sets: 4,
        },
      ],
    },
    {
      day: new Date(new Date().setDate(new Date().getDate() - 5)),
      exercises: [
        {
          type: 'resistance',
          name: 'Bench Press',
          duration: 20,
          weight: 300,
          reps: 10,
          sets: 4,
        },
      ],
    },
    {
      day: new Date(new Date().setDate(new Date().getDate() - 4)),
      exercises: [
        {
          type: 'resistance',
          name: 'Quad Press',
          duration: 30,
          weight: 300,
          reps: 10,
          sets: 4,
        },
      ],
    },
    {
      day: new Date(new Date().setDate(new Date().getDate() - 3)),
      exercises: [
        {
          type: 'resistance',
          name: 'Bench Press',
          duration: 20,
          weight: 300,
          reps: 10,
          sets: 4,
        },
      ],
    },
    {
      day: new Date(new Date().setDate(new Date().getDate() - 2)),
      exercises: [
        {
          type: 'resistance',
          name: 'Military Press',
          duration: 20,
          weight: 300,
          reps: 10,
          sets: 4,
        },
      ],
    },
  ];
  
  // When seeding, clear the collection out and repopulate it
  db.Workout.deleteMany({})
    .then(() => db.Workout.collection.insertMany(workoutSeed))
    .then((data) => {
      console.log(data.result.n + ' records inserted!');
      process.exit(0);
    })
    .catch((err) => {
      console.error(err);
      process.exit(1);
    });
  