From e6feac9e7ada9980d40ef99576bfe09806eea895 Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Sat, 26 Oct 2019 11:50:58 +1030 Subject: [PATCH] Fixed new product insert --- routes/product.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/routes/product.js b/routes/product.js index 2f35d87..d892d7b 100644 --- a/routes/product.js +++ b/routes/product.js @@ -123,6 +123,7 @@ router.post('/admin/product/insert', restrict, checkAccess, async (req, res) => return; } + // Check permalink doesn't already exist const product = await db.products.count({ productPermalink: req.body.productPermalink }); if(product > 0 && req.body.productPermalink !== ''){ // permalink exits @@ -151,9 +152,9 @@ router.post('/admin/product/insert', restrict, checkAccess, async (req, res) => } try{ - const newDoc = await db.products.insert(doc); + const newDoc = await db.products.insertOne(doc); // get the new ID - const newId = newDoc.insertedIds[0]; + const newId = newDoc.insertedId; // add to lunr index indexProducts(req.app)