I am developing an application in Express
with Mongo
. What I have to do is to read multiple records
from db
and send it to view
. There I have to render
those in table
. This is, i have done so far:
my router
:
router.route('/dashboard').get(function (req, res, next) {
res.format({
html: function () {
mongoose.model('Register').find({'userid': req.session.email}, function (err, users) {
var userMap={};
users.forEach(function(user){
userMap[user._id]=user;
});
res.json(userMap);
});
}
});
});
Here is what I get in the view:
I want to render it in the view like this:
table
tbody
tr
td #{user.pid}
td #{user.sid}
td #{user.rfname}
td #{user.des}
I refered to this but it doesn't tell how to access each record
in the view
? any help?