How to display all users database (mongodb) details on .ejs file
You need to actually query the user collection via the model's find()
query function which will return an array of user documents when executed, i.e.
var User = require('../app/models/user'); //the connection to users databaseapp.get('/profile', isLoggedIn, function (req, res) { User.find({}).exec(function(err, users) { if (err) throw err; res.render('profile.ejs', { "users": users }); }});
then render the list of user documents in your profile.ejs
as:
<% users.forEach(function (user) { %> <li> <h1><%= user.name %></h1> </li> <% }) %>