Skip to main content

Questions tagged [mongodb-query]

This tag is for questions related to querying and updating MongoDB collections, either through the mongo shell or using a programming language driver.

mongodb-query
0 votes
1 answer
33 views

MongoDB - Convert response into array of object in query

I wrote a simple query in MongoDB to get all data related to the product ID. Now I want to convert my response into an array of objects. Please see below. Query: db.collection.find({ "product_id&...
Unknown Developer's user avatar
0 votes
0 answers
46 views

Filtering MongoDB collection by date with .find() method ommits some of the records

I am trying to .filter() my MongoDB collection by date and $gte and $lte operators with the MongoDB node package. It simply doesn't work as expected and it omits some records. I have spent several ...
Primoz Rome's user avatar
  • 10.8k
-1 votes
1 answer
56 views

MongoDB Slow Query issue

I am facing slow query issue in my mongoDB database, the indexing is done properly, I have checked that there is no duplicate numeric id, even though I am getting a slow query issue. The query I am ...
AFHAM FARDEEN's user avatar
0 votes
0 answers
50 views

NestJs - How to find by id if existing record in multiple collections (mongodb)

in mongodb, i have 4 collections to save conversations and comments from Facebook and Instagram. 4 collections is facebook_page_conversations, facebook_page_comments, instagram_conversations, ...
huong1412's user avatar
1 vote
1 answer
44 views

How to exclude fields of an array using Mongo Projections

I want to only exclude the "Name" field for the "People" array field: e.g. "Type" : "Green", "Date" : "2022-10-21", "People" : [{ ...
Jackson Li's user avatar
0 votes
0 answers
47 views

How can I use mongodump in batches for collection which has millions of records

I am trying to migrate DB which has lot of collections and each collections have millions of documents. I am using mongodump and mongorestore. how can I force mongodump to dump lets say 10000 ...
dsssop's user avatar
  • 1
0 votes
0 answers
49 views

MongoServerError: E11000 duplicate key error when trying to add a video to a playlist in MongoDB

I'm working on a MERN stack application where I have a Playlist document in MongoDB that looks like this: { _id: new ObjectId('663296c9ca082f17ba715a4c'), name: 'My Fav 02', videos: [ new ...
Biswas Prasana Swain's user avatar
0 votes
0 answers
51 views

MongoDB C# Sort based on conditional column

I have an entity with 2 dates, something like this simplified entity: public sealed class Foo { public DateTime DateA { get; set; } public DateTime DateB { get; set; } } I need to sort ...
thibsc's user avatar
  • 3,949
0 votes
0 answers
27 views

getting an empty array in mongo db get request while using aggregate

so i am new to mongo db and don't know why my logic is not working...its showing me an empty array when i try to get a value of specficly something, here is the code let totalEarnedCurrentMonth; ...
ashish.oraon's user avatar
1 vote
0 answers
35 views

Restructuring data on objects to look the same by fixing properties and unwinding

I have a collection with two or more objects - that come from two different resources: [ { _id: ObjectId("123ab5fc3065ff2337479d89"), samples: [ { Set1: { ...
enavuio's user avatar
  • 1,480
1 vote
1 answer
58 views

Mongodb has 500 million documents and i want to search with regEx based on two fields in javascript driver not schema

My MongoDb has around 500 million documents looking like the following: { "_id": objectId, "Name": "John Smith", "Address": "132, My Street, Kingston,...
Jahanzaib Khan's user avatar
1 vote
2 answers
40 views

mongodb pipeline $filter with condition not $in

I want to use a pipeline to update a document by filtering on the keys of sub-documents in an object. eg data: { things: { a1: {}, ... x1: {} } } Where "things" can contain ...
iss42's user avatar
  • 2,786
0 votes
1 answer
34 views

Update a Column of a Matrix where each MongoDB document is a Row

I'm storing matrices in MongoDB where each document is a row of values. Example of two small matrices but assume there are thousands of rows and columns: [ { matrix_id: 123, row_id: 0, values: [1, 2,...
aneroid's user avatar
  • 15.3k
3 votes
1 answer
75 views

Populate Arrays inside a mongoDB document which refers the same document

I have a document which has a field as Array of References and it is refering to the same document. I want to populate all the nested fields. The Data will be Acyclic (person -> children -> ...
TheCodeVenturer's user avatar
1 vote
1 answer
131 views

Logging MongoDb queries for debugging

Log the MongoDb queries that are executed based on the business logic into console or log file. ASP.NET Core, Mongo client, Mongo DB, LINQ. I want this to understand how my queries are translated and ...
Allani Saikumar's user avatar

15 30 50 per page
1
3 4
5
6 7
1167