fix(seed): Fixes database seeding issue (#17472)

This commit is contained in:
Kory Dondzila
2018-06-06 15:27:13 -04:00
committed by mrugesh mohapatra
parent 9e840de396
commit a8756d5919
2 changed files with 17 additions and 14 deletions

View File

@@ -9,19 +9,22 @@ module.exports = function(app, done) {
const { About } = app.models;
const router = app.loopback.Router();
let challengeCount = 0;
cachedMap(app.models)
.do(({ entities: { challenge } }) => {
challengeCount = Object.keys(challenge).length;
})
.subscribe(
() => {},
err => {throw new Error(err);},
() => {
router.get('/', addDefaultImage, index);
app.use(router);
done();
}
);
if (!process.env.SEEDING) {
cachedMap(app.models)
.do(({ entities: { challenge } }) => {
challengeCount = Object.keys(challenge).length;
})
.subscribe(
() => {},
err => {throw new Error(err);},
() => {
router.get('/', addDefaultImage, index);
app.use(router);
done();
}
);
}
function addDefaultImage(req, res, next) {
if (!req.user || req.user.picture) {