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)