/r/mongodb

Photograph via snooOG

News, articles, and interesting stuff in general about MongoDB (unofficial).

/r/mongodb

23,684 Subscribers

1

I can't create database on mongodb Atlas

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."

https://preview.redd.it/yqrd254s7o0e1.png?width=2580&format=png&auto=webp&s=cd58198b4f136f9bf64a8090e499bc027a032db1

0 Comments
2024/11/13
13:27 UTC

1

Looking for Insights on MongoDB Professional Services Team: Growth, Work Culture, and Compensation

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:

  1. Career Growth: What does the typical career path look like within Professional Services? Are there good opportunities for advancement and skill development?
  2. Work-Life Balance and Pressure: How would you describe the workload and pressure in Professional Services? Is it manageable, or should I be prepared for long hours?
  3. Compensation and Hike Structure: I know compensation includes a base salary, but any insights on expected hikes, performance-based bonuses, and salary growth over time would be really helpful.
  4. Refresher Shares and Stock Options: Do employees receive refresher stock grants over time? If so, what’s the typical frequency and value?
  5. Team Culture and Outings: Lastly, how’s the team culture? Are there regular team outings or events that help balance the work with some fun?

Thanks in advance for any advice or personal experiences you can share!

0 Comments
2024/11/13
11:18 UTC

0

How to find the invalid document IDs inserted for relational queries?

1 Comment
2024/11/13
04:12 UTC

3

MongoDB Associate Developer Exam Preparation

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.

0 Comments
2024/11/13
04:11 UTC

1

High sum latency , decent avg latency. Potential root causes ?

https://preview.redd.it/2ni4wpsera0e1.png?width=2344&format=png&auto=webp&s=ba995a7de0fba910cfc21f95030e156c73147872

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 ?

1 Comment
2024/11/11
16:16 UTC

1

Help needed (mongo v7)

Hi! Do I understand correctly that the updateOne/updateMany operation with single pipeline stage (contains $set/$arrayToObject/$map/$objectToArray ops) is atomic?

1 Comment
2024/11/11
15:44 UTC

0

Help in connection

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.

3 Comments
2024/11/10
04:09 UTC

2

Difficulty with starting mongodb-community

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.

1 Comment
2024/11/08
23:52 UTC

2

Best Practices for Updating Related Documents in MongoDB with Nested User Data

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.

2 Comments
2024/11/08
07:07 UTC

1

MongoDB backup/restore GUI with scheduler

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?

5 Comments
2024/11/07
20:06 UTC

2

Questions regarding how you guys manage your self-managed mongo cluster

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.

Context:

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.

Question:

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.

1 Comment
2024/11/07
16:01 UTC

1

Mongo is unable to access data directory after macOS update (14.7 -> 14.7.1)

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.

3 Comments
2024/11/07
14:56 UTC

1

array field projection question

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

6 Comments
2024/11/07
06:18 UTC

1

querySrv ETIMEOUT _mongodb._tcp.cluster0.hkgeb.mongodb.net at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19)

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!

2 Comments
2024/11/07
01:32 UTC

2

mongorestore problem with authentication

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
2 Comments
2024/11/06
18:21 UTC

2

Cross table sorting

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.

15 Comments
2024/11/06
07:09 UTC

3

Mongo DB CE v 4.2.x - Deleting huge data - Unreliable Compact

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.

10 Comments
2024/11/05
15:37 UTC

1

Problem when deploying MERN Stack web-app with Socket.io

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

0 Comments
2024/11/05
12:14 UTC

1

Is there any mongodb client TUI?

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

9 Comments
2024/11/05
11:11 UTC

1

How can I schedule cluster auto scaling at a specific time using trigger?

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

7 Comments
2024/11/05
09:54 UTC

1

Course recommendation where I can understand the basic concepts and how MongoDB works

1 Comment
2024/11/04
04:37 UTC

1

Need Mongodb with Laravel

For years i have been trying to make mongodb work with Laravel, but fail miserably everytime. Today i need a final solution.

  1. I cant find mongodb.so file, there is only dll file on github

  2. If i use mongodb cloud does it has an rest api through i can query my data

  3. i have tried windows, linux and mac no luck

5 Comments
2024/11/04
02:47 UTC

1

implement deterministic random pagination

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.

4 Comments
2024/11/03
21:57 UTC

1

How Does MongoDB Handle Simultaneous Reads and Updates on the Same Document ?

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?

16 Comments
2024/11/03
10:45 UTC

2

Mongoose model field relation

my Schema>

const FeedbackSchema = new mongoose.Schema({
    title:{
        type:String,
        required:true,
        unique:[true,'title already exists.'],
    },
    description:{
        type:String,
        required:true
    },
    upVotes:Number,
    upVotedBy:{
        type:[String],
    }
})

how can i make the value of upVotes to the length of upVotedBy ? also values should update whenever i manipulate any document created with this schema

2 Comments
2024/11/02
11:55 UTC

2

Atlas DataLake is deprecated. What are good alternatives?

I am using Atlas DataLake to create pipelines from backup snapshots. I am then able to access these through a federated db and run large queries for analytics and reporting. Now that the DataLake is deprecated, I can no longer create pipelines for my new collections. What are good alternatives? Ideally i'd like to keep using the federated db.

1 Comment
2024/11/02
11:09 UTC

2

A Python library for analyzing and extracting the schema

Hi,

I made a simple Python library to help analyse and extract the schema of a MongoDB collection. It also can be used as a command-line tool.

I hope it's helpful for someone here.

The link to the GitHub repo: https://github.com/habedi/mongo-analyser

0 Comments
2024/11/01
22:34 UTC

1

evaluation of my design and your suggestions

context: creating the database model for the online store, which is going to have the following collection schemas (not final, could change from your suggestions)

```json

// products collection

{

"ObjectID": "...",

"Name": "...",

"Category": "...",

"Variants": [

{

"ObjectID" : "...",

"VariantName": "...",

"PriceSelling": "...",

"PriceCost": "..."

}

]

}

```

```json

// users collection

{

"ObjectID": "...",

"Username": "ObjectID(...)",

"PhoneNumber": "...",

}

```

```json

// orders collection

{

"ObjectID": "...",

"UserID": "From the users collection",

"Products": [

{

"Quantity": 0,

"ProductID": "ObjectID(...)" // id of variant

}

],

"TotalPirce": 0,

"Address": "..."

}

```

> Variants here are size, type, etc.: chocolate cupcakes, 1/10 catty of potatoes, etc. Different variants are completely different products.

I need to perform the following operations on the DB :

- find all documents from the product collection which contain specific names; I am going to use basic RegEx and indexes for the query

- Add the product they have chosen to the orders collection; I will add the variant ID here.

---

Questions now are :

  1. is my implementation okay, or is there another way to improve it?

  2. I was thinking about not having an object ID for the document in the products collections and instead having an object ID solely inside the array of documents inside there since I will only be using the object ID of specific products, not the product in general. Is this a bad idea?

  3. Is it faster to lookup using the document objectID and then using the array index subsequently when finding the specific variant, and thus, not have the objective for the variants, or is it better to lookup them by using the plain objectID of the variant (the way I described prior)?

---
I appreciate your help, and I am sorry for the very messy post.

1 Comment
2024/11/01
17:00 UTC

Back To Top