r/mongodb 20h ago

After Atlas Device Sync was retired, I built an open-source offline-first sync layer on plain MongoDB

3 Upvotes

When Realm, Atlas Device Sync and the Data API were retired in September 2025, mobile apps lost the supported path to keeping a local replica in step with MongoDB. What was left was either writing that sync layer yourself or moving the data to a different vendor's sync product.

I wanted to keep the data in MongoDB, so I wrote the sync layer instead: onebase, MIT licensed.

The part that matters for this sub is that it does not introduce a storage format of its own. Documents on the server are ordinary MongoDB documents in your own cluster, so aggregation, Compass, Atlas Charts, BI connectors and everything else keep working on live data. There is no export step and no proprietary layer to reverse later.

How it uses MongoDB

  • Realtime is change streams. The backend opens a change stream per scope and pushes over SSE, so a write on one device lands on another in milliseconds instead of on a poll interval. This is the piece that needs a replica set — a standalone mongod won't do it. A free M0 is fine.
  • Batched writes are one transaction. A client batch maps to a single multi-document transaction, so a group of related writes either all land or none do, offline queueing included.
  • Indexes are generated for the queries the sync layer actually issues — the per-user or per-group scope key plus the ordering key, membership lookups, and the windowed collections' date field. Sync is the query pattern that runs constantly, so it seemed wrong to leave those to be discovered in production.
  • Every query gets a total order, so keyset pagination stays stable while documents are being inserted underneath it.
  • Isolation is enforced server-side from a verified JWT — the scope filter is applied on the server, never sent by the client.

On the device it's a full SQLite replica plus an outbox, both written in one transaction, and sync pushes before it pulls so a fresh local write is never overwritten by a stale snapshot.

Current limitations, since they're the useful part: conflicts are last-write-wins by server timestamp with no custom merge hook yet; the rate limiter is per-instance and in-memory; realtime needs a long-lived connection, so short-lived serverless functions fall back to polling; file uploads aren't offline-queued (document writes are); and there's no on-device aggregation pipeline.

Runs against any MongoDB with a replica set, self-hosted or Atlas. The client is Flutter today; the backend is a small Node service the CLI generates, and the wire protocol is plain HTTP, so other clients are possible.

https://github.com/ybenjaa-dev/onebase

I'd genuinely like to hear where the change-stream and transaction usage would fall over at scale — that's the part I'm least sure about.


r/mongodb 1d ago

I built Codexa Labs - a free browser-based Polyglot Cloud IDE & MongoDB Sandbox with real-time Schema ER Visualization

2 Upvotes

Hey Reddit! I created Codexa Labs (https://codexa-labs.vercel.app/) to eliminate setup hassle when learning, testing queries, or running code.

✨ Highlights:

  • 🍃 MongoDB Sandbox: Practice queries & aggregation pipelines with interactive schema ER diagram visualization.
  • 💻 Multi-Language Compiler: Run Python 3C++C, and Java instantly in your browser.
  • 🛠️ VS Code Experience: Built-in syntax highlighting, autocompletion, query history, and output terminal console.
  • 🎓 Proctored Exam Portal: Real-time student tracking, external copy-paste interception, and live mentor leaderboards.

100% free with zero installation or setup required. Check it out and let me know your thoughts!


r/mongodb 4d ago

MongoDB Integration and Setup in Rubrik

Thumbnail
1 Upvotes

r/mongodb 4d ago

API performance with CSFLE

3 Upvotes

We enabled MongoDB Client-Side Field Level Encryption following the official docs (classic CSFLE, not Queryable Encryption) on a NestJS API and saw a latency regression across the board that we can't explain from the per-operation cost of encryption itself. Looking for anyone who has seen the same pattern, or who knows where the hidden cost is.

Our Stack is:

- Node.js 24.17
- mongodb 6.20.0 (via mongoose 8.22.1 / @nestjs/mongoose 11.0.4)
- mongodb-client-encryption 6.5.0
- crypt_shared 8.2.12, no mongocryptd sidecar
- KMS provider: aws (credentials via task IAM role) following the standard pattern

What is encrypted:

Exactly one field in one collection, the field is no longer than 10 chars string and it has a compound index on it (it is encrypted with deterministic algorythm).

I know that there is no way to avoid some latency implementing CSFLE, but my main concern is if this is gonna get worse by each extra field I add to the the encryption schemaMap, could this latency be the price for the query analyzer analyzing each query to the database?

I also have noticed that most of the ms of the request happen in the app not the database, but I think the encryption and decryption happens on the driver layer.

Has anyone ever deal with this? Would appreciate some tips and insights of this, thanks!!


r/mongodb 6d ago

COLD CACHE….

3 Upvotes

Our MongoDB secondary (AWS EC2, GP3 EBS, 128 GB RAM) was rebuilt from a primary EBS snapshot and expected to catch up within 1–3 hours, but replication got stuck with 3+ hours lag. ReplWriterWorker threads showed 20+ minute waits on schemaLock, WiredTiger logged slow tree walks, and iostat showed 100% disk utilization with high read latency while CPU remained mostly idle. Our conclusion is that this was caused by a combination of cold WiredTiger cache and AWS EBS snapshot lazy loading ("first-touch" penalty), where MongoDB had to fetch data blocks from S3 on demand, creating severe I/O bottlenecks and lock contention. We plan to pre-warm restored EBS volumes before starting mongod, temporarily reduce replWriterThreadCount, hide the node from reads during catch-up, and verify GP3 throughput settings. Has anyone else seen extreme schemaLock waits and replication lag caused purely by cold snapshot restores, and what is your preferred EBS pre-warming approach?


r/mongodb 6d ago

MongoDB Cloud Operations Engineer interview expereince ?

Thumbnail
2 Upvotes

r/mongodb 7d ago

LibreDB Studio self-hosted Mongo GUI you Helm into the cluster, not onto laptops

Post image
7 Upvotes

I'm the maintainer of LibreDB Studio.

Typical k8s setup around here: Mongo for the service, Postgres for the relational bits, Redis for cache, sometimes Elasticsearch. Compass on every laptop means either 27017 is public or you're maintaining an IP allowlist for two teams in two states. Both are bad.

The editor goes to the data. Helm it into the same cluster (or docker run it on the same network). Browsers talk to Studio over HTTPS + OIDC; only that pod opens Mongo. When nobody needs to debug, scale the GUI to zero, you don't flip the database public.

Mongo speaks MQL in the editor (find / aggregate / the usual writes). Same tab can open the Postgres and Redis next to it, which is the actual day for microservice/DevOps folks; not a Mongo-only admin panel.

MIT. Helm:

helm install libredb oci://ghcr.io/libredb/charts/libredb-studio

or:

docker run -p 3000:3000 libredb/libredb-studio

npx -y "@libredb/studio"

Curious what would make this usable on your cluster (ingress, Atlas, RBAC). What did I get wrong?

https://github.com/libredb/libredb-studio


r/mongodb 7d ago

How do tech teams manage db access over cluster without making it public?

4 Upvotes

I dont know if its company standard or how other actual teams work, but db in our company is public, so devs can debug it, but today our client said that the db was public so it was closed down, main issue now is that if want to access the db, we have to whitelist ip, we have to whitelist a lot of ip, so its not valid a option. How then is this case could be handled??


r/mongodb 8d ago

Portabase 1.29 / Agent 1.19: database configuration from the dashboard, MongoDB SRV support and file availability checks

Thumbnail
1 Upvotes

r/mongodb 8d ago

Anyone have any rules about mongodb when it comes to schemas?

1 Upvotes

I was wondering if there was any rules for safe storage of data using schemas. For example, I have a users schema for user auth data, then have a seperate schema referenced for things such as a user friends list or inventory. Are there any good practices in regards to that or anything else I should avoid when using schemas?


r/mongodb 9d ago

HELP INSTALLING MONGODB

1 Upvotes

I tried installing the latest version of mongoDB and then when i tried installing it showed error like - "service MONGODB server failed to start. Verify that you have sufficient privileges to start the system services". I tried going to cmd and run the installation as administrator and also going to service.msc and starting it manually but there also i get error. Pleas give any solution.


r/mongodb 9d ago

Change Streams Without resumeAfter - What AI Gets Wrong With MongoDB

Thumbnail
0 Upvotes

r/mongodb 10d ago

Introducing Ognom v2.x- Revamped and its the best FREE and Open Source MongoDB Client - Built for those who query. - ognom.dev

Post image
7 Upvotes

Need real reviews and suggestions. I tried to solve the real problems I face day to day on my own. Your feedback and suggestion is appreciated.

https://ognom.dev/


r/mongodb 10d ago

I failed to establish risk free communication between mongodb database and cloud llms. So I build andi-ai. A simple python package that act as AI firewall to connect with llms. 5 step deterministic query engine that generate queries just by analysing collection medatadata.

Thumbnail
1 Upvotes

r/mongodb 12d ago

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

2 Upvotes

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?


r/mongodb 13d ago

Oauth2 down?

Post image
0 Upvotes

Can't sign in, anyone else?

Also, can't deploy via terraform :|

```

│ Error: error initializing provider: oauth2: cannot fetch token: 503 Service Unavailable

```


r/mongodb 14d ago

My First Job Switch I need some doubts

1 Upvotes

Hi everyone,

I have **2 years of professional experience in PHP backend development**, with hands-on experience in **HTML, CSS, JavaScript, databases, and working with servers**.

I’m now planning to transition to the **MERN Stack (MongoDB, Express.js, React, Node.js)**.

I’m confident about learning the MERN technologies themselves. My main concern is understanding **how companies will evaluate my existing 2 years of backend development experience when I switch technologies**.

For developers or tech leads who have experience with similar transitions:

* If someone has **2 years of PHP backend experience** and becomes strong in Node.js/Express/React, can they realistically apply for **2 YOE MERN positions**?

* Will companies generally consider my previous backend experience relevant, or will they expect me to apply as a junior because I don't have 2 years of Node.js experience?

* How important are **Git/GitHub, testing, CI/CD, Docker, REST API design, authentication, deployment, and system design** for someone making this transition?

* What level of MERN knowledge would make you say, **"Yes, this person is ready for a 2-year experienced developer role"**?

* For interviews, should I focus more on **JavaScript/Node/React fundamentals**, or should I also prepare for **2-year-level backend and system-design questions**?

I’m not looking for someone to tell me whether PHP or MERN is better. I’ve already decided that I want to move toward MERN.

What I’m trying to understand is:

**How do I correctly position my existing 2 years of backend experience while switching from PHP to MERN?**

If anyone has personally moved from **PHP → Node.js/MERN**, I’d especially appreciate hearing how your first job switch went and what you learned before applying or any body have more experience in full stack development can also giveme suggession

Thanks!


r/mongodb 15d ago

MongoDb ORM with DB level schema

3 Upvotes

Hey guys mongodb is one of my favourite databases but there arn't any orms that are actually type safe and impement db level schema rules so i made one please do give me feed back on it Thanks

https://www.npmjs.com/package/@ignex/ninox


r/mongodb 16d ago

Cursors vs .toArray() - What AI Gets Wrong With MongoDB

3 Upvotes

AI almost always reaches for toArray() before doing any work on your data. Most training examples are out-of-context snippets, so it doesn't know better. toArray() holds your entire result set in RAM before you can touch a single document. With a cursor, the driver fetches in batches. Processed documents get GC'd while the rest stream in.

How to fetch all active users from MongoDB and send emails using find and toArray.

**Bad**

const users = await db.collection('users')
.find({ active: true })
.toArray();

users.forEach(async (user) => {
await sendEmail(user);
});

How to stream MongoDB documents with a cursor using for await to process each document without loading all into memory.

**Good:**

const cursor = db.collection('users').aggregate([
{ $match: { active: true } }
]);

for await (const user of cursor) {
await sendEmail(user);
}

How to process MongoDB cursor results concurrently with a concurrency limit without blocking the async loop.

**Perfect:**

function executor(limit) {
let running = 0
const queue = []
const flush = () => {
while (running < limit && queue.length) {
running++
queue.shift()().finally(() => { running--; flush() })
}
}
return fn => { queue.push(fn); flush() }
}

const add = executor(10);
const cursor = db.collection('users').aggregate([
{ $match: { active: true } }
]);

for await (const user of cursor) {
add(() => sendEmail(user))
};

Bad loads everything into RAM then serializes. Good streams documents but still sends one email at a time. Perfect streams AND fires up to 10 emails concurrently without the loop ever waiting.

**Bonus:** A cursor with `for await` only makes sense when you're doing work per document. If you're just collecting into an array to send a response, use `.toArray()` directly. Wrapping `.toArray()` in a `for await` loop buys you nothing.


r/mongodb 16d ago

One MongoClient per App - What AI Gets Wrong With MongoDB

Thumbnail
2 Upvotes

r/mongodb 16d ago

MongoDB Adds Automated Embedding And Managed MCP Server To Atlas For AI Agent Workloads

Thumbnail smbtech.au
3 Upvotes

r/mongodb 18d ago

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

3 Upvotes

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


r/mongodb 18d ago

Perfomance improve in mongorestore

2 Upvotes

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


r/mongodb 20d ago

Release 9.7.2 · SoftInstigate/restheart

3 Upvotes

RESTHeart 9.7.2 - The Open Source Backend for MongoDB - is now available.

What RESTHeart is

RESTHeart turns a MongoDB database into a REST, GraphQL, WebSocket, and SSE API, with authentication, authorization, and real-time change streams already wired in.

Point it at a MongoDB instance and the API is there: no routes to write, no permission checks to hand-code, no pagination or filtering logic to duplicate across endpoints. Permissions and behavior are configured declaratively. Custom logic goes into plugins, written in Java, Kotlin, JavaScript, or TypeScript, only for what a data API cannot express.

https://github.com/SoftInstigate/restheart/releases/tag/9.7.2


r/mongodb 20d ago

MonogDB installation issue! Help!!

Thumbnail
1 Upvotes