17,491 questions
0
votes
0
answers
38
views
Mongoose intermediate data saving in DB
I have a branch management system in my application where some approved requests show the processor's name (like "usernme") while others show "Legacy".
The issue
Logs always show ...
1
vote
1
answer
69
views
golang issue when parsing data to bson for mongodb
I am having a strange (to me) an issue with golang mongodb connector. The current problem is that I have a db retrieval function that actually returns no errors, but the struct expected is just not ...
1
vote
1
answer
61
views
In a MongoDB transaction, are index entries updated immediately when an indexed field is modified?
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 ...
Best practices
0
votes
3
replies
67
views
Mongodb Using aggregates for advanced search
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 ...
3
votes
1
answer
64
views
Query not printed as expected
exports.getAllProducts = async (req, res) => {
try {
console.log(req.query);
const queryObj = { ...req.query };
const excludedFilters = ["page", "limit", "...
-1
votes
1
answer
56
views
Mongo unexpected mongo queries
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 ...
1
vote
0
answers
50
views
Watching for changes on an array of a document in a Mongo collection only triggers on the second push, not the first
Say I have a document in a Mongo collection that looks like the following:
{
"_id": "01:550204",
"somefield1": "someValue1",
"somefield2": "...
-2
votes
1
answer
98
views
In MongoDB, is there a performance difference between $in covering all possible values vs leaving the field out in a compound index?
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", "...
-3
votes
1
answer
103
views
query that tries to match everything does not use the index [closed]
https://mongoplayground.net/p/2CHyeuaG0y0
db.test.aggregate([
{
$match: {
$or: [
{
cheese: {
"$exists": true
}
},
{
...
0
votes
1
answer
88
views
All fields except _id disappeared from a MongoDB document after a $set operation
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 ...
0
votes
1
answer
95
views
Does MongoDB update an index when array elements are only reordered?
I’m working with a collection where documents contain an array of subdocuments, for example:
{
"_id": 1,
"tasks": [
{ "priority": 2, "dueDate": "...
-1
votes
1
answer
78
views
Can MongoDB use a compound index to sort when filtering with $in?
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,
...
0
votes
1
answer
58
views
Performance impact of updating leading vs. trailing fields in a MongoDB compound index
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 ...
2
votes
0
answers
145
views
MongoDB Atlas connection error: queryTxt ETIMEOUT with Mongoose
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 ...
-2
votes
1
answer
85
views
can mongoDB use the full depth of a compound index on an array of subdocuments?
index:
{
"name": "tar",
"key": {
"tar.a": 1,
"tar.b": 1
}
tar is an array of subdocuments.
query:
...