Skip to content

Sabbir Mohammad Sami web developer

ResumeDownload Resume

All notes

(Backend Development)8 min read

Express.js and MongoDB: A Comprehensive Guide

A reference for building a REST API with Express.js and the official MongoDB Node.js driver: connecting with MongoClient, then one route per operation — find all, find by id, filter, paginate with skip and limit, insert, upsert with PUT, update with PATCH, delete and count — each paired with the fetch call that uses it from a React client.

The MongoDB leaf and the Express “ex” mark in two linked white circles on a green gradient, captioned “Express MongoDB Short Note”

Basic Setup

Embedded on index.js to Connect:

JavaScript
const express = require("express");
const cors = require("cors");
const { MongoClient, ServerApiVersion, ObjectId } = require("mongodb");
const jwt = require("jsonwebtoken"); // import jwt if use JsonWeb token
require("dotenv").config(); // import env file if use environment variables after install || npm install dotenv --save|| ane Create a .env file in the root of your project:
const port = process.env.PORT || 5000;
const app = express();
// used Middleware
app.use(cors());
app.use(express.json());
// Connact With MongoDb Database
const uri = `mongodb+srv://${process.env.DB_USER}:${process.env.DB_PASS}@cluster0.krxly.mongodb.net/?retryWrites=true&w=majority`;
const client = new MongoClient(uri, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  serverApi: ServerApiVersion.v1,
});
// Create a async fucntion to all others activity
async function run() {
  try {
    await client.connect();
    // Create Database to store Data
    const testCollection = client.db("testDatabaseName").collection("testData");
  } finally {
    // await client.close();
  }
}
// Call the function you declare abobe
run().catch(console.dir);
// Root Api to check activity
app.get("/", (req, res) => {
  res.send("Hello From NR Computers!");
});
app.listen(port, () => {
  console.log(`NR Computers listening on port ${port}`);
});

Get Method

Get/Access all data from MongoDB database

Server Site Code:

JavaScript
app.get("/service", async (req, res) => {
  const result = await testCollection.find().toArray();
  res.send(result);
});

Client Site Code:

JavaScript
useEffect(() => {
  fetch("http://localhost:5000/service")
    .then((res) => res.json())
    .then((data) => console.log(data));
}, []);

Get/Access Specific data from MongoDB database with id/email

Server Site Code:

JavaScript
app.get("/service/:id", async (req, res) => {
  const id = req.params.id;
  const result = await testCollection.find({ _id: new ObjectId(id) }).toArray();
  res.send(result);
});

Client Site Code:

JavaScript
useEffect(() => {
  fetch(`http://localhost:5000/service/${id}`)
    .then((res) => res.json())
    .then((data) => console.log(data));
}, []);

Get/Access Specific data from MongoDB database with multiple queries

Server Site Code:

JavaScript
app.get("/service", async (req, res) => {
  const query = req.body;
  const result = await testCollection.find(query).toArray();
  res.send(result);
});

Client Site Code:

JavaScript
const query = {
  email: "exampale@example.com",
  name: "set name",
  time: "set time",
};
useEffect(() => {
  fetch("http://localhost:5000/service", {
    method: "GET",
    body: JSON.stringify(query), // send any of query by which you find data
  })
    .then((res) => res.json())
    .then((data) => console.log(data));
}, []);

Get/Access Limited data from the MongoDB database after finding the query

Server Site Code:

JavaScript
app.get("/service", async (req, res) => {
  const query = {};
  const findData = testCollection.find(query);
  const result = await findData.skip(5).limit(3).toArray(); // you can also set skip & limit range dynamicly.
  res.send(result);
});

Client Site Code:

JavaScript
useEffect(() => {
  fetch("http://localhost:5000/service")
    .then((res) => res.json())
    .then((data) => console.log(data));
}, []);

Post Method

Post data without checking on MongoDB database

Server Site Code:

JavaScript
app.post("/service", async (req, res) => {
  const service = req.body;
  const result = await testCollection.insertOne(service);
  res.send(result);
});

Client Site Code:

JavaScript
const newData = {
  // store new Data in Object here
  name: "",
  price: "",
};
fetch("http://localhost:5000/service", {
  method: "POST",
  headers: {
    "content-type": "application/json",
  },
  body: JSON.stringify(newData),
})
  .then((res) => res.json())
  .then((result) => {
    const allData = [...previusData, newData];
    console.log(newReview);
  });

Post data With check-in MongoDB database. Better to use Put Method for this task

Server Site Code:

JavaScript
app.post("/service/:email", async (req, res) => {
  const service = req.body.service;
  const query = req.body.newQuery;
  query.email = email;
  const exist = testCollection.findOne(query);
  if (exist) {
    res.send({ result: "success" });
  } else {
    const result = await testCollection.insertOne(service);
    res.send(result);
  }
});

Client Site Code:

JavaScript
const service = {
  name: "",
  price: "",
};
const newQuery = {
  name: "",
  time: "",
};
fetch("http://localhost:5000/service", {
  method: "POST",
  headers: {
    "content-type": "application/json",
  },
  body: JSON.stringify({ service, newQuery }),
})
  .then((res) => res.json())
  .then((result) => {
    const allData = [...previusData, newData];
    console.log(newReview);
  });

Put Method

Update & insert Data on the database by id/email/otherQuery

Server Site Code:

JavaScript
app.put("/service/:id", async (req, res) => {
  const id = req.params.id;
  const service = req.body;
  const result = await testCollection.updateOne(
    { _id: new ObjectId(id) }, // Find Data by query many time query type is "_id: id" Cheack on database
    {
      $set: service, // Set updated Data
    },
    { upsert: true } // define work
  );
  res.send({ result });
});

Client Site Code:

JavaScript
const updatedData = {
  name: "",
  role: "",
};
fetch(`http://localhost:5000/service/${id}`, {
  method: "PUT",
  headers: {
    "content-type": "application/json",
  },
  body: JSON.stringify(updatedData),
})
  .then((res) => res.json())
  .then((data) => {
    alert("item Updated successfully!!!");
  });

Patch Method

Update Data by id/email/othersQuery

Server Site Code:

JavaScript
app.patch("/service/:id", async (req, res) => {
  const id = req.params.id;
  const service = req.body;
  const result = await testCollection.updateOne(
    { _id: id }, // sometime _id: new ObjectId(id)
    {
      $set: service,
    }
  );
  res.send(result);
});

Client Site Code:

JavaScript
const updatedData = {
  name: "",
  role: "",
};
fetch(`http://localhost:5000/service/${id}`, {
  method: "patch",
  headers: {
    "content-type": "application/json",
  },
  body: JSON.stringify(updatedData),
})
  .then((res) => res.json())
  .then((data) => {
    alert("item Updated successfully!!!");
  });

Delete Method

Delete Data from MongoDB Database by id

Server Site Code:

JavaScript
app.delete("/service/:id", async (req, res) => {
  const id = req.params.id;
  const result = await testCollection.deleteOne({ _id: new ObjectId(id) });
  res.send(result);
});

Client Site Code:

JavaScript
fetch(`http://localhost:5000/service/${_id}`, {
  method: "DELETE",
})
  .then((res) => res.json())
  .then((data) => {});

Count the number of arrays

Server Site Code:

JavaScript
app.get("/billsCount", async (req, res) => {
  const count = await billCollection.countDocuments();
  res.send({ count });
});

Common Questions

How do I connect Express.js to MongoDB?
Install express, mongodb, cors and dotenv, create a MongoClient with the connection string from your .env, and call await client.connect(). Then take a collection with client.db('name').collection('items') and use it inside your route handlers.
How do I find a MongoDB document by id in Node.js?
Wrap the id in ObjectId: collection.findOne({ _id: new ObjectId(req.params.id) }). MongoDB stores _id as an ObjectId, not a string, so a query with the raw string from the URL matches nothing.
What is the difference between PUT and PATCH in a REST API?
PUT replaces the whole resource — with upsert: true it also creates the document when it does not exist yet. PATCH changes only the fields sent, through $set, and leaves everything else as it was.
How do I paginate MongoDB results in Express?
Read the page and size from the query string and call collection.find().skip(page * size).limit(size).toArray(). Return countDocuments() alongside, so the frontend knows how many pages there are.
Topic
Backend Development
Published
Reading
8 min · 985 words
Sections
8
Tags
  • Express.js
  • MongoDB
  • Node.js
  • REST API
  • CRUD

Experience

( 03 roles — 2+ years )

Full-stack developer in Dhaka, Bangladesh. Building for clients in Germany and Bangladesh since 2022.

  1. (01)

    August 2025 — Present

    Full-Stack Developer

    Susko GmbH · Full Time · Remote

    • Developed and enhanced an AI-powered SaaS and social media automation platform — AI content, image and video generation, automated scheduling and publishing, multi-account and content-team management, Meta, Instagram and Google integrations, WhatsApp-based content generation and scheduling, admin controls and subscription management.
    • Built a full-stack Padel court management and automation system that connects physical court hardware to a real-time web dashboard — court and player management, game control and live scores over WebSocket — and worked on the sensor electronics, PCB design, footprint verification, Gerber validation and JLCPCB manufacturing.
    • Built and maintained automation workflows with n8n, webhooks, APIs and external service integrations that take manual steps out of business processes.
    • Delivered 40+ production websites and full-stack applications for German clients across industries in React, Next.js and TypeScript — shop management, review management and automation, fundraising platforms, menu management, QR code generation and other custom business tools.
    • Optimized backend performance across production applications — database queries, API paths, data processing and Redis-based workflows — for faster, more responsive apps.

    Next.js · React · TypeScript · Node.js · Python · Prisma · Redis · WebSocket · n8n · OpenAI

  2. (02)

    March 2024 — May 2025

    Software Developer

    Bangladesh Associate of IT Solutions · Full Time · On-site

    • Developed a full-stack inventory management system tracking products, sales, payments, returns, waste products, customer ledgers and SMS notifications, in React, TypeScript, Express and MySQL.
    • Scaled an accounting management platform from a single-client application into a multi-user system, with financial dashboards, journal entries, transaction management, reporting and data visualization.
    • Deployed and maintained web applications on cPanel and VPS servers — production deployments, domain configuration, server setup and troubleshooting.
    • Delivered websites for schools, madrasas and other organizations, turning client requirements into responsive, production-ready web applications.
    • Developed and redesigned production and company portfolio websites in React, Next.js and TypeScript, with a focus on responsive design and user experience.

    React · Next.js · TypeScript · Express · MySQL · Tailwind CSS · cPanel · VPS

  3. (03)

    November 2023 — April 2024

    Full-Stack Developer

    Diginie IT · Internship · Remote

    • Completed a remote internship as a full-stack developer, building and maintaining client web applications in Next.js, TypeScript and Tailwind CSS.
    • Turned designs into responsive pages that held together on every screen size, and kept existing client sites running.

    Next.js · TypeScript · Tailwind CSS · GitHub

About

( Dhaka, Bangladesh )

Sabbir Mohammad Sami — full-stack web & app developer at Susko GmbH, building for the web since 2022.

Sabbir Mohammad Sami, smiling and looking off to the side, seated on a white block in a black sweater — black-and-white studio portrait

I’m a full-stack developer from Dhaka who cares about the part people actually touch — unusual layouts, careful CSS, motion that means something — and about the code underneath being just as clean.

( Story )

I grew up in Dhaka and studied arts and humanities at Kabi Nazrul Government College. Alongside my studies I joined a web development course, and that is where the real growth started — surprise. Alongside work, I am now in my third year of Honours in Economics at National University.

My first website was a tourism site about the place I most wanted to visit. I built it in class 10.

Today I build AI products, automation and client platforms at Susko GmbH, after two years of shipping inventory, accounting and client sites at BAITS. What I am after has not changed: interfaces that look good and back-ends that run smoothly, from the same pair of hands.

Honest, down to earth, and fond of hard work. My inbox is always open — for a project, or just to say hi.

  1. ( Education )

    1. Kabi Nazrul Government College

      • Arts and humanities
      • Dhaka, Bangladesh
    2. National University, Bangladesh

      Session 2023–2024 · Now

      • Honours in Economics — 3rd year
      • Department of Economics
  2. ( Co-curricular )

    —

    Bangladesh National Cadet Corps (BNCC)

    • 1 No Battalion, Ramna Regiment
    • Rank: Cadet Corporal
  3. ( Languages )

    Bangla, English, Hindi

    • Bangla — native
    • English — comfortable
    • Hindi — fluent

( Skills )

Expertise
React · Next.js · JavaScript · TypeScript · MongoDB · Bootstrap · Tailwind CSS · shadcn/ui · GitHub · Figma
Comfortable
Flutter · Dart · MySQL · Mongoose · Express · TanStack Query · Firebase · React Router · Photoshop
Familiar
Zod · Framer Motion · GSAP · JWT · Axios · CORS · Stripe · Vercel

( Questions )

Who is Sabbir Mohammad Sami?

Sabbir Mohammad Sami (S M Sami) is a full-stack web and app developer from Dhaka, Bangladesh. Since August 2025 Sami has worked as a Full-Stack Developer at Susko GmbH in Germany, after building inventory and accounting platforms at Bangladesh Associate of IT Solutions (BAITS). Sami has been building for the web since 2022.

What does Sabbir Mohammad Sami build?

Sami builds websites, web apps, mobile apps and AI products end to end: company and restaurant websites, booking and management platforms, an AI social media platform (Kocial), an AI review manager (ReviewSync) and a Flutter money app (Sompi). That includes 40+ production websites for clients in Germany and Bangladesh.

Which technologies does Sami work with?

Sami works across the MERN stack — MongoDB, Express, React and Node.js — and with Next.js, TypeScript, Tailwind CSS, MySQL, PostgreSQL, Prisma and Redis. Mobile apps are built in Flutter and Dart. AI features use the OpenAI API, n8n automations and webhooks, and motion uses GSAP.

Does Sami build mobile apps with Flutter?

Yes. Sami builds cross-platform apps in Flutter and Dart. Sompi, Sami’s own money tracker, runs on Android, iOS, the web and the desktop from one Flutter codebase, with Riverpod for state and an encrypted SQLite store, so every account and transaction stays on the device.

Does Sami build AI products?

Yes. At Susko GmbH Sami builds AI SaaS: Kocial writes captions, generates images and publishes to Facebook and Instagram for agencies, and ReviewSync answers Google reviews in a business’s own voice. Sami also builds n8n workflows that connect AI models to business tools.

How can I hire Sami as a web or app developer in Dhaka?

Email smsami.dev@gmail.com or use the contact form on this site with a short note about the project. Sami works with clients in Dhaka, across Bangladesh and abroad — remotely for companies in Germany — and replies in English or Bangla.

( Contact )

Contact

( Available for projects )

Based in Dhaka, Bangladesh (GMT+6). Happy to talk in English, Bangla or Hindi.

Let’s work together.

Have an exciting project you need help with? Send me an email, give me a call, or write below — a project, a question, or just to say hi.

( Write to me )

* Required