Skip to main content
Image

r/node


Why is anyone still using Drizzle over Prisma?
Why is anyone still using Drizzle over Prisma?

Seriously. I've used Prisma for years but in the interest of giving different libraries a shot, I opted for Drizzle for my latest project.

The types are weird. It feels more like a table-relational mapping than an object-relational mapping.

If you really want granular control over your database but don't want to write SQL, then fine. Apart from that and being lighter, I've yet to find a good reason to use it over Prisma.

Can anyone convince me otherwise?


Advertisement: Join engineering, security, AI, and platform leaders at swampUP 2026 in New York, Sept 1-3. Instructor-led labs, hands-on training, and sharp breakout sessions.
Join engineering, security, AI, and platform leaders at swampUP 2026 in New York, Sept 1-3. Instructor-led labs, hands-on training, and sharp breakout sessions.
Image Join engineering, security, AI, and platform leaders at swampUP 2026 in New York, Sept 1-3. Instructor-led labs, hands-on training, and sharp breakout sessions.


Reached ~192 Stars! Built a Terminal Torrent client that searches every trusted source at once and downloads straight to disk
Reached ~192 Stars! Built a Terminal Torrent client that searches every trusted source at once and downloads straight to disk
media poster

Is alright the order of my code?
Is alright the order of my code?

Hello,

I want to know if everything from App setup should be below or above the Connect to MongoDB & create server:

// Dependencies

const express = require("express");
const mongoose = require("mongoose");
const Blog = require("./models/blog");

// Variables

const app = express();
const PORT = 4000;

// Connect to MongoDB & create server

async function connectToDatabase() {
  try {
    const dbURI = "ABC";
    const mongooseInstance = await mongoose.connect(dbURI, { dbName: "nodejs-db" });
    console.log("Connected to MongoDB database");

    const server = app.listen(PORT, () => {
      console.log(`Server is listening on port ${PORT}`);
    });
  }
  catch (error) {
    console.log("An errror occured:", error);
  }
}
connectToDatabase();

// App setup

app.set("view engine", "ejs");
app.use(express.static("public"));

// Node.js routes

app.get("/", (req, res) => {
  res.render("index");
});

app.get("/about", (req, res) => {
  res.render("about");
});

// Mongoose - Save blog

app.get("/add-blog", (req, res) => {
  const doc = new Blog({
    title: "Add new blog",
    snippet: "About my new blog",
    body: "More about my new blog"
  });

  async function saveDoc() {
    try {
      const savedDoc = await doc.save();
      res.send(savedDoc);
    }
    catch (error) {
      console.log("An error occured:", error);
    }
  }
  saveDoc();
});

// Mongoose - Display blogs in descending order by date

app.get("/blogs", (req, res) => {
  async function getBlogs() {
    try {
      const getBlogs = await Blog.find().sort({ createdAt: -1 });
      res.render("blogs", { title: "Blogs", blogs: getBlogs });
    }
    catch (error) {
      console.log("An errror occured:", error);
    }
  }
  getBlogs();
})

// 404 handler

app.use((req, res) => {
  res.status(404).render("404");
});

Thank you.