title: What is missing from this delete process node.js?
body: <p>The edit works fine, but it seems fundamentally different from the delete since the edit actually goes to a different page. This is part of a project where we're kinda just piecing together code that was given to us and adding a few lines here and there, but I don't know what is missing from the delete. </p>
  
  <p>The request gets the item id, the query looks like a correct delete function to me, and the rest is just printing results? The delete button works, but that's all i can see. </p>
  
  <p><a href="https://i.stack.imgur.com/jS8vL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jS8vL.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/ipsWr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ipsWr.png" alt="enter image description here"></a></p>
  
  <p>delete--</p>
  
  <pre><code>app.delete('/delete/(:id)', function(req, res, next) {
      req.getConnection(function(error, conn) {
          conn.query('DELETE from store where id = ' + req.params.id, function(err, result) {
  
              if (rows.length &lt;= 0) {
                  req.flash('error', err)
                  // redirect to users list page
                  res.redirect('/store')
              } else {
                  req.flash('success',
  
                      )
                  // redirect to users list page
                  res.redirect('/store')
              }
          })
      })
  })
  </code></pre>
  
  <p>edit--</p>
  
  <pre><code>app.get('/edit/(:id)', function(req, res, next) {
  
      req.getConnection(function(error, conn) {
          conn.query( 
              'SELECT * From store Where id = ' + req.params.id, function(err, rows, field) {
              // if item not found
              if (rows.length &lt;= 0) {
                  req.flash('error', 'Item not found with id = ' +
                      id )
                  res.redirect('store/edit')
              } else { // if item found
                  // render to views/store/edit.ejs template file
                  res.render( 'store/edit' , {
                      title: 'Edit Item',
  
                      id: req.params.id,
                      qty:rows[0].qty ,
                      price: rows[0].price,
                      sname: rows[0].sname
                  })
              }
          })
      })
  })
  
  
  app.put('/edit/(:id)', function(req, res, next) {
      req.assert('sname', 'Name is required').notEmpty()
      //Validate name
      req.assert('qty', 'Quantity is required').notEmpty()
      //Validate qty
      req.assert('price', 'Price is required').notEmpty()
      //Validate price
      var errors = req.validationErrors()
      if (!errors) { //No errors were found. Passed Validation!
  
      var item = {
          sname: req.sanitize('sname').escape().trim(),
          qty: req.sanitize('qty').escape().trim(),
          price: req.sanitize('price').escape().trim()
      }
  
          req.getConnection(function(error, conn) {
              conn.query('Update store set ? where id =' + req.params.id, item, function(err, result) {
                  if (err) {
                      req.flash('error', err)
                      // render to views/store/edit.ejs
                      res.render('store/edit', {
                          id: req.params.id,
                          sname: item.sname,
                          qty: item.qty,
                          price: item.price
                      })
  
                  } else {
                      req.flash('success', 'Data updated successfully!')
                      // render to views/store/edit.ejs
                      res.render('store/edit', {
                          title: 'Edit Item',
                          id: req.params.id,
                          sname: item.sname,
                          qty: item.qty,
                          price: item.price
                      })
                  }
              })
          })
  
      }
      else {
          var error_msg = ''
          errors.forEach(function(error) {
              error_msg += error.msg + '&lt;br&gt;'
          })
          req.flash('error', error_msg)
  
          res.render( '/store/edit', {
              title: 'Edit Item,',
              id: req.params.id,
              sname: req.body.sname,
              qty: req.body.qty,
              price: req.body.price ,
          })
      }
  })
  </code></pre>
  
  <p>form content--</p>
  
  <pre><code>&lt;form method="post" action="/store/delete/&lt;%= item.id %&gt;"
          style="float:right"&gt;
          &lt;/form&gt;
          &lt;input type="submit" name="delete" value='Delete'
          onClick="return confirm('Are you sure you want to delete?')" /&gt;
          &lt;input type="hidden" name="_method" value="DELETE" 
  </code></pre>