So it’s hard for me to understand how to delete a record in my database with the click of a button on my screen. Logic just doesn't make sense to me. My view is as follows:

How to get each button to connect to each record? I have listed my view and route code below so you can skip it.
Jade
extends ../userLayout
block localStyles
link(rel='stylesheet', href='/stylesheets/usersPage/users.css')
block content
.container
.users.col-md-11.col-xs-12.table-responsive
h1 Current Users
form.form(method="post" action="/users/view")
table.col-xs-12
tr
th Name
th Username
th
each user in users
tr
td= user.name
td= user.username
td
button.btn.btn-danger.col-xs-12 X
user route
router.post('/view', function(req, res, next) {
userSchema.remove({ name: 'reg' }, function (err) {
if (err) return handleError(err);
});
});
As I said, my big problem is just the logic of getting a button to delete a specific record. Any help would be greatly appreciated.
source
share