Skip to content

Instantly share code, notes, and snippets.

@blackwright
Created April 28, 2017 14:38
Show Gist options
  • Save blackwright/0de752845956c66911fa3454a59b4c3b to your computer and use it in GitHub Desktop.
Save blackwright/0de752845956c66911fa3454a59b4c3b to your computer and use it in GitHub Desktop.
Mongoose Seeds Index
const mongoose = require('mongoose');
const models = require('../models');
Object.keys(models).forEach((modelName) => {
global[modelName] = mongoose.model(modelName);
});
require('../mongo')()
.then(() => console.log('Cleaning Database...'))
.then(() => {
return require('./clean')();
})
.then(() => console.log('Seeding...'))
.then(() => {
return require('./seeds')();
})
.then(() => console.log('Done'))
.catch((e) => console.error(e))
.then(() => mongoose.disconnect());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment