Express js CRUD Tutorial using mongodb.(Show)

1. app.js

const allController = require('./homeController')
app.get('/show', allController.getAllUser)

2. homeController.js

const user_model = require('./user_model') // include user_model.jsexports.getAllUser = async (req, res, next) => {
let user_data = await user_model.find()

3. Create Show.ejs file:

vim show.ejsblog_expressjs/views/show.ejs<table class="table">

<% for(let p of user_data) { %>
<th><%= %></th>
<td><%= p.title %></td>
<td><%= p.description %></td>
<a class="btn btn-md btn-success">Edit</a>
<a class="btn btn-md btn-danger">Delete</a>
<% } %></tbody>




Software Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

All about React’s shouldComponentUpdate()

An introduction to observables in Reactive Programming

::ng-deep alternatives

Microservices from Scratch (1): Project Overview

JavaScript: Array Methods Cheatsheet

Structural directives

React Functionality

Callbacks in JavaScript

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Safaetul Ahasan

Safaetul Ahasan

Software Engineer

More from Medium

Create Node js-express API from Scratch

Google Drive API, Resumable upload — Javascript

Node Js With MongoDB

Creating a Web Server With Node.js using HTTP Module and Logging the Requests.