r/mongodb

MongoDB + Docker + .NET: A Simple Local Development Setup
▲ 3 r/mongodb+1 crossposts

MongoDB + Docker + .NET: A Simple Local Development Setup

If you're working with MongoDB and .NET, Docker can make the local development setup much simpler.

Instead of installing and configuring MongoDB directly on your machine, you can run it in a Docker container and connect your .NET application to it.

I put together a practical guide covering:

  • Creating a MongoDB Docker container
  • Configuring MongoDB
  • Connecting a .NET Core application
  • Understanding the container-to-application connection
  • Setting up a consistent local development environment

📖 https://geeksarray.com/blog/create-mongodb-docker-image-and-connect-from-dot-net-core-app

For those using MongoDB locally, what's your preferred setup—Docker, local installation, or something else?

u/geeksarray — 20 hours ago
▲ 6 r/mongodb+1 crossposts

One MongoClient per App - What AI Gets Wrong With MongoDB

AI puts this in every route file it touches:

    const client = new MongoClient(uri);
    await client.connect();
    // query
    await client.close();

Looks clean. Problem is a MongoClient is a POOL, up to 100 connections. A free Atlas cluster takes 500 total. Five of these alive at once and your whole cluster budget is gone before one query runs. Then everyone blames Mongo for "randomly dying under load".

One client for the whole app. Create it once, import it everywhere. The driver does the pooling, that is literally its job.

Bonus AI also never gets right: Next.js dev SSR mode re-runs module scope on every hot reload. Your correct singleton turns into a new pool every time you hit save. Cache it on globalThis and it survives reloads:

    let client = globalThis._mongoClient;
    if (!client) {
      client = new MongoClient(process.env.MONGODB_URI);
      globalThis._mongoClient = client;
    }

Costs nothing in production, saves your dev cluster.

Grep your codebase for "new MongoClient". If you have more than one, you have a problem.

Make a module you import, and reuse so every script imports the same active connection.

    // db.js
    import { MongoClient } from 'mongodb';

    export const client = new MongoClient(process.env.MONGODB_URI, {
      appName: 'my-api',
    });

    export const db = client.db('app');
reddit.com
u/TimAtMongoDB — 4 days ago

How did my Node.js + MongoDB API take 13 seconds to respond? 😭

How did my Node.js + MongoDB API take 13 seconds to respond? 😭

I recently ran into a performance issue in one of my backend APIs.

The API was built with Node.js + MongoDB, and the response time was nearly 13 seconds. 🫠

At first, I thought:

“Maybe MongoDB is slow?”

But obviously, there was more going on.

Now I'm trying to identify the actual bottleneck and optimize the API properly — database queries, indexing, population/aggregation, unnecessary processing, network calls, etc.

For developers who have worked on Node.js + MongoDB production APIs:

What would you check first when an API takes ~13 seconds to respond?

Would love to hear how you would debug this step-by-step

reddit.com
u/PickAffectionate1938 — 7 days ago
▲ 1 r/mongodb+1 crossposts

MonogDB installation issue! Help!!

I am learning backend dev and have switched from using wsl2 to fedora. But having issues downloading MongoDB.
From all the gpt'ing I found out this :
Your Fedora kernel: 7.1.7

MongoDB 8.0.28: refuses to start

Error message: "6.19 and newer"

right now its recommending me to uninstall MongoDB completely and install it against but this time use Podman + MongoDB container(i don't have the slightest idea about what its talking about, im just a beginner for ffs!!😭)
So what should i do now??
can someone help me setup my Linux environment(focused on backend dev)
also recommend me some extensions/tools/apps that would make my life navigating fedora(GNOME DE) much easier!

P.S if possible can you dm me, i have some question regarding setting my up linux for backend dev🙏

reddit.com
u/WrongCandidate4160 — 9 days ago

Perfomance improve in mongorestore

I have a replica set cluster, and every 15 min there is 1.5GB data that is being dumped from oplog.

At the end I am trying for restores, withe the help of mongorestore tool with total of such 118 oplog dumps.

It takes around 10-15 min each for all the oplog dumps to be restored, in total of 9 hrs.

Is there any other way we can improve the perfomance

reddit.com
u/woolneat — 7 days ago

mongodb-agent vulnerability free image.

We are struggling with compliance requirements around the official MongoDB Agent container image. Our company policy mandates that all production images have zero Critical or High severity vulnerabilities.

Even across new version releases, we see the same fixable Critical/High CVEs lingering in the base image components. Because the image source isn't public, we can't patch and rebuild it ourselves without risking broken dependencies or vendor support issues.

What strategies are teams using to address this? Are people creating custom wrapper images, filing enterprise support requests, or using specific vulnerability suppression/exception workflows for third-party proprietary agents?

reddit.com
u/adityashrivastav — 10 days ago
▲ 12 r/mongodb+2 crossposts

QueryForge – the LLM never writes the query, it fills in a typed AST

Hi everyone!

Over the past few months I've been building QueryForge, an open-source Go library that takes a different approach to natural language querying.

Most text-to-SQL systems ask an LLM to generate SQL directly.

The problem I kept running into was that, even with prompts and post-processing, the model could still invent columns, widen filters, or produce queries that were technically valid but not what the user intended.

So I flipped the architecture.

Instead of generating SQL, the LLM only fills in a typed Query AST.

Everything after that is deterministic Go:

Natural Language
        ↓
      LLM
        ↓
   Typed Query AST
        ↓
 AST Validation
        ↓
 SQL / Mongo Compiler

Some of the things this enables:

  • Unknown fields become validation errors with suggestions.
  • SQL injection isn't sanitized—it simply isn't representable in the AST.
  • DELETE/UPDATE operations don't exist in the AST.
  • Multi-tenant filters are injected after validation, so the model never even knows the tenant column exists.
  • The same AST can target multiple backends (currently PostgreSQL and MongoDB).

The core library uses only the Go standard library and is released under Apache-2.0.

I've also built a live demo where you can:

  • type natural language
  • inspect the generated AST
  • inspect the generated SQL
  • try invalid fields
  • try prompt injections
  • see how validation behaves

Live Demo
https://queryforge-demo.amtry.in

GitHub
https://github.com/awsaman-ai/queryforge

u/awsamanai — 12 days ago

mongo db for solo indie dev

hello after searching for a stack that fit me well i found sveltekit remote function when adding mongo db with agregate framework from day one one of the simplest with best dx stack for someone just start learning and making apps pairing with atlas for fast deployment but when i read about mongo all i found is negative feedbacks and advices about avoid it at all cost for my side it s clicked more tryng to embeed as much as i can no schema just using zod for validation

is there here solo developers that made theirs own saas with mongo with active ? if yes how s your experience does aggregate framework enough for all you needs and not feeling the need to use an sql database ? thanks for the feedback

reddit.com
u/LiteratureWrong304 — 14 days ago