Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
40 views

I'm working with MongoDB transactions (Node.js, replica set). Inside a transaction, I update a document in a way that changes the value of a field that is covered by an index. Later in the same ...
Bear Bile Farming is Torture's user avatar
Best practices
0 votes
1 replies
57 views

Trying to solve a conundrum I have in writing some queries. I’ve traditionally used simple find operations (and cursor operations for paging functionalities), but need something more complex to ...
Snappawapa's user avatar
  • 2,082
3 votes
1 answer
58 views

exports.getAllProducts = async (req, res) => { try { console.log(req.query); const queryObj = { ...req.query }; const excludedFilters = ["page", "limit", "...
ahmad fakher's user avatar
0 votes
1 answer
53 views

i have some problems in production using mongo We have python using mongo and mongo-express for ui. And we are facing performance issues, after research i found db.currentOp() to see queries which are ...
Zesshi's user avatar
  • 524
1 vote
0 answers
47 views

Say I have a document in a Mongo collection that looks like the following: { "_id": "01:550204", "somefield1": "someValue1", "somefield2": "...
djsumdog's user avatar
  • 2,828
-2 votes
1 answer
95 views

I’m working with a MongoDB compound index like this: db.users.createIndex({ gender: 1, city: 1, age: 1 }) Suppose city has only a few possible values, e.g., "Chicago", "LA", "...
Bear Bile Farming is Torture's user avatar
-3 votes
1 answer
97 views

https://mongoplayground.net/p/2CHyeuaG0y0 db.test.aggregate([ { $match: { $or: [ { cheese: { "$exists": true } }, { ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
85 views

I'm using MongoDB Atlas 7.0 on a dedicated cluster and encountered a bizarre issue where a document in one of my collections mysteriously lost all its fields except for the _id. I performed a ...
ARTK's user avatar
  • 1
0 votes
1 answer
91 views

I’m working with a collection where documents contain an array of subdocuments, for example: { "_id": 1, "tasks": [ { "priority": 2, "dueDate": "...
Bear Bile Farming is Torture's user avatar
-1 votes
1 answer
71 views

I have a users collection with a compound index: db.users.createIndex({ bin: 1, gender: 1, age: 1, location: 1, // ... other fields }); When I query like this: db.users.find({ bin: X, ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
55 views

I am working with MongoDB and have a compound index on a collection, e.g., { a: 1, b: 1 }. I want to understand the performance implications when updating documents with respect to the fields in this ...
Bear Bile Farming is Torture's user avatar
2 votes
0 answers
137 views

Mongoose connection to MongoDB Atlas fails with queryTxt ETIMEOUT I’m trying to connect my Node.js app to MongoDB Atlas using Mongoose, but the connection fails with a timeout error. Here’s the error ...
Kevin L's user avatar
  • 21
-2 votes
1 answer
83 views

index: { "name": "tar", "key": { "tar.a": 1, "tar.b": 1 } tar is an array of subdocuments. query: ...
Bear Bile Farming is Torture's user avatar
-5 votes
1 answer
78 views

Given a aggregation pipeline like this, in which I use a $match with { $exists: false } on a indexed field: db.collection.aggregate([ { $match: { myField: { $exists: false } } } ]) ...
Bear Bile Farming is Torture's user avatar
2 votes
1 answer
154 views

I have a MongoDB replica set deployed in a Kubernetes cluster using the MongoDB Kubernetes Operator. I can connect to the database using mongosh from within the cluster, but when I try to connect ...
Rashid's user avatar
  • 31
0 votes
1 answer
103 views

I want to do this in ColdFusion RecurringType = rc.db.RecurringType .find() .sort({ "SortOrder" : 1 }) .project({_id : 0}) .toArray(); However I get an error message of ...
James A Mohler's user avatar
0 votes
1 answer
67 views

I'm using Mongoose with a MongoDB collection where the userId field is defined as required in my schema like this - userId: { type: String, required: true, ref: 'user' } When I fetch document ...
Mohammad Noushad Siddiqui's user avatar
0 votes
1 answer
60 views

How to group by and count value of field which is in list? I have documents looks like this: [ {"_id": "some_id","uuid": "unique_uuid", "my_field": [{&...
Zesshi's user avatar
  • 524
1 vote
1 answer
44 views

I have the following object in MongoDB. { _id: "9839021321", forms: [ { formName: "sample_form_name", version: [ { version: "1", ...
Felipe Vidal's user avatar
2 votes
1 answer
88 views

db.collection.updateOne( { _id: "unique_object_id", field_a: 5 }, { $inc: { field_a: 1 } } ) Let's suppose that in the collection, only one document has field_a equaling 5, ie, only ...
Bear Bile Farming is Torture's user avatar
3 votes
1 answer
104 views

const orders = await db1.db.collection("order_all").find({ progress_status_kd: { $in: [32, 33] }, ps_screen_preparing_n_packaging_permission: true, $expr: { $lte: [ ...
suvro's user avatar
  • 78
0 votes
2 answers
60 views

while starting from mongod.conf using below entry mongod not running throwing error: mongod.service : main process exited, code=exited, status=2/INVALIDARGUMENT IN MONGD.CONF: when commenting ...
prat_86's user avatar
  • 91
0 votes
1 answer
50 views

I'm building an Expense Tracker web app using Java Servlets and MongoDB. I want to filter expense documents based on user and category (e.g., user: "chir", category: "education"). ...
CHIRSMITA THAKUR's user avatar
0 votes
1 answer
88 views

I'm using MongoDB Atlas and noticed a warning in the Performance Advisor and monitoring dashboard: "Query Targeting: Scanned Objects / Returned" has gone above 1000 From my understanding, ...
Annamalai's user avatar
  • 134
0 votes
1 answer
68 views

The user collection in my MongoDB database needs to be searched to find content for my users. Each user has their list of blocked users. const suggested_content = await db.collection('users').find({ ...
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
91 views

I have a MongoDB collection that contains several fields with dots, like: { "symbol.name": "Some name" "symbol.state": "Some state" // etc. } Now, ...
Nikolay Kovalenko's user avatar
0 votes
1 answer
81 views

I have a document like this: { id: string, subDocCount: number, subDocs: [ { id: string (not an ObjectId), dateField: Date, booleanField: boolean } ] } I want to set ...
ThriceGood's user avatar
  • 1,713
0 votes
0 answers
23 views

The below listed function is not giving captains in radius data while creating a ride with user. It is accepting the latitude and longitude. I tried to log the data at every step, whole code is ...
Kushagra Sahu's user avatar
1 vote
1 answer
66 views

In MongoDB (version 8) I'm wondering about the most read-efficient way of storing a "sharing mechanism". I.e. the users can share items with other items within the same collection. When ...
cis's user avatar
  • 1,403
0 votes
1 answer
30 views

Hi so we have a few collections in my mongo db. for which we have normal indexes created other than primary key. none of those index are ttl indexes. but in mongo db graph we keen seeing ttl delete ...
RIA Phoniex's user avatar
0 votes
0 answers
33 views

I have a collection named ‘policies’ which references control in its field 'associatedControls' from collection ‘controls’ and control has a field 'associatedFrameworks' where it references 'framework'...
Fuaad's user avatar
  • 480
0 votes
0 answers
60 views

I'm trying to update the subArray elements by the key, adding the value. I'm using the latest version of the library. In the new approach, the "AllMatchingElements" method is used. It seems ...
padavan's user avatar
  • 929
0 votes
1 answer
58 views

I'm trying to create a patch API for a database of products in a MERN application that keeps track of expiry dates. The idea is when a product's UPC is given, as well as the date in which it expires, ...
Ian McInnes's user avatar
1 vote
1 answer
68 views

For a particular type of query, I have the choice between 2 indexes. I ran an example of the query with hint and explain to compare them, with the following output: Metric Index 1 Index 2 nReturned 1 ...
EV_alt's user avatar
  • 15
2 votes
1 answer
91 views

I am working on MongoDB, which has a model as below: const appJobSchema = new mongoose.Schema({ data: [ { type: Schema.Types.Mixed } ], stat: { dataCount: { type: Number, ...
user824624's user avatar
  • 8,168
2 votes
1 answer
116 views

We do have a collection with around 20million documents of this structure: { _id: ... learnerId: <string> type: <string> organizationId: <string> timestamp: ISODate ...
Stefan's user avatar
  • 897
1 vote
2 answers
60 views

Sample documents of a collection DB: MYDB Collection: MYCOLL { "_id": { "$oid": "678a78375cb6955814197272" }, "ID": 1019397, "INFO&...
Shahan's user avatar
  • 59
0 votes
0 answers
35 views

IIUC, $near calculates the Euclidean distance using latitude, and longitude (which I think would be an approximation), whereas $nearSphere calculates the great-circle distance using latitude and ...
Kalcifer's user avatar
  • 1,739
-3 votes
1 answer
47 views

Update nested object values in array, we have multiple objects in array. { "_id" : ObjectId("5a7e395e20a31e44e0e7e284"), "name" : "a", "...
muni's user avatar
  • 23
0 votes
1 answer
43 views

Using Mongo 6.0 in a NodeJS application, I have a collection where each document can have an array of mandatoryCourseIds or electiveCourseIds or both. A sample could look like this: [ { &...
cis's user avatar
  • 1,403
1 vote
1 answer
47 views

I am using the following aggregate pipeline in MongoDB to traverse a two-way graph: { $match: { from: "some_root" } }, { $graphLookup: { from: "connections", startWith: &...
basse's user avatar
  • 1,383
0 votes
1 answer
72 views

Issue I get "Alice Maria Bobsson" when I search with "Alicex Flicex" (Solution 1) I don't get "Alice Maria Bobsson" when I search with "Alice Bobsson" (...
Christian Nilsson's user avatar
1 vote
2 answers
294 views

I was using $dateTrunc on a timeseries collection to group the timeseries data from 2024-12-01 to 2024-12-07 into a single bin. Here is the aggregate pipeline: [ { $match: { timestamp: { ...
tattzetey's user avatar
0 votes
1 answer
37 views

To put it simply I have a list of locations, where each location has it's own long, lat and radius. I need to check whether an input long, lat is inside any of the locations, so just comparing the ...
Abdelrahman Ibrahim's user avatar
0 votes
0 answers
54 views

Can I convert this aggregation pipeline updates into Spring Data MongoDB(Reactive) with type check? I mean, it'd be the best if compile error occurs when the name of field in @Document class changes. ...
Sean Hwang's user avatar
0 votes
0 answers
70 views

I am building a Laravel application on top of a MongoDB instance. For the ORM layer I am using the official MongoDB Driver / Eloquent Implementation. The DB contains JSON documents that have been ...
jschpmr's user avatar
  • 98
0 votes
0 answers
40 views

I want to create an index on qualityConfirmations attribute and query it. As qualityConfirmations has dynamic fields at the root level for eg. 228, 234, and inside that I need to query for "...
Pawan Kumar's user avatar
0 votes
1 answer
196 views

I have two collections: store_group collection: {"_id": ObjectId("674fe7cc4e65df54a0db23b5"), "stores": [ {"id": 101, "name":"abc&...
user468587's user avatar
  • 5,071
0 votes
0 answers
87 views

I am using MongoDB Atlas, and my data is stored like this: {"abc": "123"}, {"def": "456"} ] Now, I want to create a search index on this collection with ...
Wicket's user avatar
  • 1
0 votes
2 answers
83 views

The data in mongodb is like this { "_id": "1", "a": 1, "b": 2, "c": 3 "d": 4 } I can update the document using a single ...
Bruce's user avatar
  • 606

1
2 3 4 5
350