Small fix for indexing products

master
Mark Moffat 2019-06-19 10:52:04 +09:30 committed by GitHub
parent de5a01c671
commit 0972565124
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,7 @@
const express = require('express'); const express = require('express');
const common = require('../lib/common'); const common = require('../lib/common');
const { restrict, checkAccess } = require('../lib/auth'); const { restrict, checkAccess } = require('../lib/auth');
const { indexProducts } = require('../lib/indexing');
const colors = require('colors'); const colors = require('colors');
const rimraf = require('rimraf'); const rimraf = require('rimraf');
const fs = require('fs'); const fs = require('fs');
@ -137,7 +138,7 @@ router.post('/admin/product/insert', restrict, checkAccess, (req, res) => {
let newId = newDoc.insertedIds[0]; let newId = newDoc.insertedIds[0];
// add to lunr index // add to lunr index
common.indexProducts(req.app) indexProducts(req.app)
.then(() => { .then(() => {
req.session.message = 'New product successfully created'; req.session.message = 'New product successfully created';
req.session.messageType = 'success'; req.session.messageType = 'success';
@ -253,7 +254,7 @@ router.post('/admin/product/update', restrict, checkAccess, (req, res) => {
res.redirect('/admin/product/edit/' + req.body.frmProductId); res.redirect('/admin/product/edit/' + req.body.frmProductId);
}else{ }else{
// Update the index // Update the index
common.indexProducts(req.app) indexProducts(req.app)
.then(() => { .then(() => {
req.session.message = 'Successfully saved'; req.session.message = 'Successfully saved';
req.session.messageType = 'success'; req.session.messageType = 'success';
@ -283,7 +284,7 @@ router.get('/admin/product/delete/:id', restrict, checkAccess, (req, res) => {
} }
// remove the index // remove the index
common.indexProducts(req.app) indexProducts(req.app)
.then(() => { .then(() => {
// redirect home // redirect home
req.session.message = 'Product successfully deleted'; req.session.message = 'Product successfully deleted';