/r/mongodb
News, articles, and interesting stuff in general about MongoDB (unofficial).
Learn MongoDB
/r/mongodb
I know that Realm device sync is deprecated but end of life is in September 2025. I’m developing an app and it has very tight first release deadlines and it can be redeveloped by the time end of life comes around. Main question is it still working at least?
If I can add documents to collections just by referencing them without defining the collection first, can I do the same for indexes?
Maybe when I initialize the MongoClient, I also call createIndex() and if it exists, MongoDB is smart enough to ignore the create? Or is it better to run getIndexes and check the array first before calling createIndex everytime?
Hello, I am building an offline first app where the data should be present and changeable even if offline and user can do this from multiple devices. Our backend is using MongoDB and app is using react-native. as I understand Realm is now depreacated. Any options you recommend?
Only constraints are really using mongo and react-native. I looked at few options such as watermelonDB, redux-offline and pouchDB. All of them require a bunch of custom logic for working and I'm afraid of messing up some synchronization logic like consistency and conflics.
what is the most straightforward approach in your opinion?
Hi, I am doing a task where i need to send data from a Java application to a MongoDB database by using a message broker (they adviced RabbitMQ), and I am having lots of trouble in making them work together.
I manage to create MongoDB databases and RabbitMQ queues seperatley, but im not managing to make the data from the queues get inserted into the database.
I have tried loads with chatgpt, but cant get it to work. Anyone have any tips or resources to help?
I can't create database on a recently created cluster. The button "Create database" is continuosly loading and when hover it shows me the message "Data explorer is loading, you will be able to create a database once it has loaded."
I recently received an offer for a role with the Professional Services team at MongoDB, and I’d love to hear from anyone with experience on the team (or with MongoDB in general). I’m particularly interested in understanding a few key areas:
Thanks in advance for any advice or personal experiences you can share!
Hello I started studying MongoDB and planning to take the MongoDB Associate Developer Exam. My reasons for taking this are reward money and for my resume. I'm a developer and currently following the MongoDB learning path for node.js developers. Is that path enough for the test or do I need more supplements?
Just for the background, I tried MongoDB once few years ago and now, I already forgot it.
I am on m10 cluster. how come only user collection has high total latency and not average latency.
user documents < 100
total documents across all collections < 500
What are those latency number here ? how do you guys find root cause ?
Hi! Do I understand correctly that the updateOne/updateMany operation with single pipeline stage (contains $set/$arrayToObject/$map/$objectToArray ops) is atomic?
Hey everybody, this is my first post here. I am working on a client where I need to extract data from MongoDB atlas, how shall I do?
I have seen couple of videos and got to know that I can connect atlas to compass and then extract the data.
Problem is : I'm getting confused on which username and password to keep in the connection url?
Please help me out asap so that it will be easy for me😭.
Feel free to dm me.
I have been trying to use mongodb for a project and have been encountering errors trying to get it working again. I decided to reinstall homebrew and mongodb but i am still getting this following error when i run brew services list
:
mongodb-community error 256 root ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
I check the logs at /opt/homebrew/var/log/mongodb/mongo.log
and saw this in the logs:
{"t":{"$date":"2024-11-06T22:09:37.381-08:00"},"s":"I", "c":"NETWORK", "id":5693100, "ctx":"initandlisten","msg":"Asio socket.set_option failed with std::system_error","attr":{"note":"acceptor TCP fast open","option":{"level":6,"name":261,"data":"00 04 00 00"},"error":{"what":"set_option: Invalid argument","message":"Invalid argument","category":"asio.system","value":22}}}
Im not sure if this is a permission issue or if I need to customize something in the plist file. If anyone has any advice or suggestions it would be greatly appreciated.
I’m looking for advice on maintaining consistency between documents in MongoDB collections where data is duplicated. Specifically, I want to ensure that updating user data in the users
collection automatically reflects in all related documents in the certificates
collection.
Hello, i am searching the web for a automatic back-up scheduler software for MongoDB community.
I tried Comet but the restore is very slow, normal dump and restore are fast.
It does not have to be free, but not with the controller in the cloud but old fashion locally.
Hope i missed some great software along my search?
Hello everyone!
I'm a new member here, and I wanted to introduce myself. I'm an SRE engineer at my company, and I'm currently tackling an issue with our self-managed MongoDB cluster.
We have a MongoDB cluster running on AWS, with two EC2 instances and EBS volumes attached. The setup includes one primary instance for write operations and one replica set for reads. Recently, we’ve been experiencing significant replica lag spikes, which have led to degraded performance and, in some cases, downtime.
The issue seems to stem from a CVE database in our cluster around 130GB. Another team has been running read queries on this database, some of which are over 90GB, and this has been placing a lot of stress on the MongoDB instances, causing lag between the primary and replicas. Even smaller queries (~100MB) are occasionally contributing to these lag spikes. As a result then our application could not operate correctly, which led to production affected.
I'm reaching out you guys here might have advice on preventing this from happening. May be somehow isolating the CVE database from our critical database and handling the larger queries separately and any other way to operate self-managed mongo cluster to solve this issue? We’re lacking expertise in MongoDB cluster management, any insights or recommendations on how we can better manage this load would be greatly appreciated!
Thank you very much for your help.
I updated my macOS version and after that, Mongo is refusing to start. Logs say NonExistentPath: Data directory /data/db not found.
I checked my conf file and the Storage is set to dbPath: /usr/local/var/mongodb
like it should. I went there and while there is no 'data' or 'db' folder, I checked Time Machine and everything looks like it has before.
What could be wrong? Maybe Mongo can no longer access the directory for some reason?
I have mongodb-community stable 8.0.1 installed via Homebrew on an Intel Mac. Can anyone help me figure this out? Thanks in advance.
So far I have tried to restart the computer and manually restart the mongodb-community service. Also I have tried reinstalling the package.
I have the variants array which contains documents which contain field "CostP". To improve performance, how can I project certain fields of the array's documents? Something like
client.OnlineStore.Products.find_one(
{"Variants": {"$elemMatch": {"vID": (ObjectId("67270858c76a0350f53ca704"))}}},
{"Name": 1, "Variants.$": 1, "Variants.CostP": 1},
)
but which doesn't cause error :). Thank you
Has anyone ever gotten this issue when connecting to their Mongo Atlas cluster through their app connection string using the Node.js driver?
My app have been connecting to this database cluster for more than 3 years with no problems. Then suddenly, a couple weeks ago, it started encountering this error and crashing. Here is the error response from the mongo atlas server:
Error: querySrv ETIMEOUT _mongodb._tcp.cluster0.hkgeb.mongodb.net at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19)
When I checked the clusters and its connection string, they match the applications environment data.
When I pinged both "_mongodb._tcp.cluster0.hkgeb.mongodb.net" and the connection host "cluster0.hkgeb.mongodb.net", I received "Unknown host" response.
When I pinged "cluster0-shard-00-01.hkgeb.mongodb.net", I recieved an infinite loop responding with: "64 bytes from 34.197.137.113: icmp_seq=37 ttl=240 time=116.257 ms", "64 bytes from 34.197.137.113: icmp_seq=38 ttl=240 time=130.185 ms", ...
When I pinged "_mongodb._tcp.cluster0-shard-00-01.hkgeb.mongodb.net", I received the response: "cannot resolve _mongodb._tcp.cluster0-shard-00-01.hkgeb.mongodb.net: Unknown host".
Any help will be greatly appreciated. Thanks!
Hi,
I am trying to restore a dump to a database with this command on RHEL9.4
# mongorestore "mongodb://dguser:password@mongo218.cat.dog/datagerry" \
--gzip -d datagerry --authenticationDatabase=datagrerry .
2024-11-06T19:10:00.875+0100 error connecting to host: failed to connect to \
mongodb:// dguser:password@ mongo218.cat.dog/datagerry: connection() error \
occurred during connection handshake: auth error: sasl conversation error: unable to\
authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.
Great. But this works just fine with the same credentials and authentication database:
# mongosh "mongodb:// mongo218.alphacredit.acgroup/datagerry" \
--username= dguser _user --password password \
--authenticationDatabase datagerry
Current Mongosh Log ID: 672bb07d4cdbee9c6c2202d7
Connecting to: mongodb://<credentials>@ mongo218.cat.dog/datagerry?directConnection=true&authSource=datagerry&appName=mongosh+2.2.5
Using MongoDB: 6.0.15
Using Mongosh: 2.2.5
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
datagerry>
Why does the mongorestore complain?
Here are the versions installed:
# rpm -qa|grep mongo
-org-mongos-6.0.15-1.el9.x86_64
mongodb-org-server-6.0.15-1.el9.x86_64
mongodb-mongosh-2.2.5-1.el8.x86_64
mongodb-database-tools-100.9.4-1.x86_64
#
# mongorestore --version
mongorestore version: 100.9.4
git version: ce6af0fefca324ad5d9cb689d335130f48c99699
Go version: go1.20.12
os: linux
arch: amd64
compiler: gc
How do I sort a response from a table according to the other table's key?
For example: I have a table named user data. The contents of the table is:
{ _id:objectId,
name:string,
age:number}
Now I have another table named employee salary data. The contents of the table is:
{ _id:objectId
userId:objectId //ref to user
totalSalary:number}
What I want here is that when I fetch a data from the employee salary, I want to sort the result by the user's name (which is in the user table) or totalSalary (whichever the user inputs on the order that user mentioned)
I am using mongoose 8.4.5 if there is any query that I can use in mongoose, please let me know. If you prefer aggregate pipeline please give me a code example as I am new to aggregation pipelines.
We're managing a MongoDB database that has reached 10TB in size and continues to grow daily. We're using the community edition, version 4.2.x. To control the database size, we're planning to run a continuous purge job to delete old documents.
However, we're encountering issues with the compact
operation. It has proven unpredictable—compact times for the same collection and similar volumes of deleted data vary significantly between runs, which makes it difficult for us to reliably schedule or plan around it.
Given that we're deleting large amounts of data, we're concerned about the potential performance impact over time if we skip running compact
. Has anyone experienced performance degradation in MongoDB under similar conditions without regularly compacting? Any insights or suggestions would be greatly appreciated.
I have a MERN Stack project, which has a folder for both front-end and back-end separately, the same thing for git repository (means that I have 2 repos for FE and BE differently).
And I got some problems related to the connection:
Failed to load resource:
http://localhost:5000/socket.io/userId=undefined&EIO=4&transport=polling&t=PByEOBe
net::ERR_CONNECTION_REFUSED
GET
http://localhost:5000/socket.io/?userId=undefined&EIO=4&transport=polling&t=PByEP6f
net::ERR_CONNECTION_REFUSED
Have anyone deployed on MERN Stack app using Socket before could share me some experience?
Here is my link to my repo (in the testDeploy-branch):
Front-end: https://github.com/trangiahaodev/threads-clone-frontend
Back-end: https://github.com/trangiahaodev/threads-clone-backend
Thanks you guys so much, I appreciate any help
Hi fellows! As the title says, is there any MongoDB client terminal UI out there that you use/recommend?
I've been using compass lately. It has everything that I need but it just doesn't fit my workflow. Changing windows and moving my hand to the mouse for clicking/opening collections on compass is annoying me. At the same time, using mongo shell from the terminal is too verbose just to check one attribute on a collection.
I wonder if there's any kind of terminal UI for mongo kind of similar to compass where I can access my pre-config DBs, open collections and it shows the documents. Something like that.
Does anyone know any?
EDIT: AdHour1983 suggested https://www.vi-mongo.com/docs/introduction. It fits my needs! tyty
I have tried this guide https://www.mongodb.com/developer/products/atlas/atlas-cluster-automation-using-scheduled-triggers/#
And I can’t find any function snippet provided by the Atlas.
Edit: Solved
For years i have been trying to make mongodb work with Laravel, but fail miserably everytime. Today i need a final solution.
I cant find mongodb.so file, there is only dll file on github
If i use mongodb cloud does it has an rest api through i can query my data
i have tried windows, linux and mac no luck
I need to implement pagination that appears random but needs to be deterministic based on a seed value. The main challenge is that when querying documents using specific indexed fields, I want the results to be randomly ordered, but this randomness needs to be consistent - meaning if I use the same seed, I should always get the same order of results, and different seeds should produce different (but still consistent) orderings.
I have a scenario where two requests read the same document in MongoDB simultaneously. If the first request updates the document after reading it, how does the second request know about the updates? Specifically, if both requests read the document before any updates occur, will the second request’s changes be based on the original state, or will it see the updates made by the first request? Can someone please clarify how MongoDB handles this situation?