Created
April 28, 2017 14:38
-
-
Save blackwright/0de752845956c66911fa3454a59b4c3b to your computer and use it in GitHub Desktop.
Mongoose Seeds Index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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