1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-24 14:31:30 +00:00
Files
homebrewery/scripts/populate.js
2017-06-04 22:03:36 -04:00

27 lines
699 B
JavaScript

//Populates the DB with a bunch of brews for UI testing
const _ = require('lodash');
const DB = require('../server/db.js');
const BrewData = require('../server/brew.data.js');
//const BrewGen = require('../tests/brew.gen.js');
const BrewGen = require('../shared/homebrewery/snippets/brew/brew.snippet.js');
const BREW_COUNT = 50;
return Promise.resolve()
.then(DB.connect)
.then(BrewData.removeAll)
.then(() => {
return _.reduce(_.times(BREW_COUNT, BrewGen.brewModel), (flow, model)=>{
return flow.then(()=>BrewData.create(model))
}, Promise.resolve());
})
.then(() => {
console.log(`Added ${BREW_COUNT} brews`);
})
.then(() => {
return DB.close();
})
.catch(console.error);