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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
9 views

Mongo filter function doesn't work on embedded/nested List in Spring Aggregation using either project or addField

I've tried multiple methods to get Mongo's filter tool to work on Spring Aggregation function. I'm using version 3.1.0 of Spring Boot starter along with the mongo data starter package that comes with ...
tlarson's user avatar
  • 363
-1 votes
0 answers
19 views

how to store result of equal operation of two fields into a third field in mongodb? [closed]

I have a document stored in MongoDB in below manner. { "_id": "123", "list": [{ "uploaded" : false "num": 3, "...
Sameer's user avatar
  • 1
1 vote
1 answer
30 views

I need to fetch records grouped datewise(dates) ,daywise(monday,tuesday,....sunday) and hourwise(1,2,3...23,24) in mongodb

Below is the format of mongo table records { _id: ObjectId("656efc1366c7dce6da3185e3"), a: '656e5e0c6c773c4374b0b14a', b: '656e5e346c773c4374b0b14b', c: 'abc', d: '...
MDL's user avatar
  • 21
0 votes
0 answers
67 views

Deletting nested document from an array of fields

I have an array of products in a mongo document and I have been try to get one product and delete it, but I haven't been able to do that. async deleteOneStoreProduct(storeId: string, productId: string)...
Richardebrain's user avatar
1 vote
0 answers
50 views

$dateToString not outputting in MongoDB query

For the following MongoDB (5.0.14) query, I'm experiencing some strange behaviour with the $dateToString command for a projection. The failDateStr value causes an error which results in the projection ...
jesus g_force Harris's user avatar
-4 votes
0 answers
44 views

MongoDB sharding problem - "ending idle connection to host because the pool meets constraints" [closed]

after I referred https://www.youtube.com/watch?v=Jr0PiGIVJ8k this video and when I activated mongos, and tried to connect with mongosh --port 27017, mongos haven't started and I saw "ending idle ...
mkbmob1004's user avatar
0 votes
0 answers
52 views

Large collections or Tabels [closed]

I am working on project which needs different tables or a collection set for each user. Let's assume I have 1000 users, 20 tables each - in total, 20000 tables. What database technology should I ...
amit's user avatar
  • 9
0 votes
1 answer
22 views

Is it possible to do case-insensitive search on Keys/Fields in MongoDB? with Typescript

For example a way to treat or detect a field "productionYear" in DB against "productionyear". So can I do caseinsentive search on both fields and values?
N.A's user avatar
  • 195
1 vote
1 answer
39 views

Mongo $lookup not working after another $group

I have an aggregation query like this to group the categories which have a post const categoriesWithPosts = await Models.Post.aggregate([ { $match: { active: true }, }, { ...
Hamza Fudda's user avatar
0 votes
1 answer
54 views

How to populate a populated field name in mongoose

this is my example populated result: I need to populate the popoluated field name from 'fileInfo' Inside fileInfo i need to populate the filed name 'createdBy' { _id: new ObjectId("...
Rohit tdr's user avatar
1 vote
1 answer
42 views

Difference Between Placing `$match` Before or After `$unwind` in MongoDB Aggregate for My BooksDB

Hello MongoDB community, I am trying to understand the difference in the results and performance implications between two aggregate queries in MongoDB. Both queries aim to count the number of books ...
omersk's user avatar
  • 13
2 votes
1 answer
47 views

How to combine multiple arrayFilters for a single key

Let's say I have a schema in this format: const some_schema = new mongoose.Schema({ "id": { type: Number }, "list": [ { id: { type: Number }, ...
zinbrox's user avatar
  • 123
0 votes
1 answer
29 views

MongoDB .find() method doesn't work in Kotlin, in KTOR framework

I'm trying to use the .find() method with no arguments to return all the documents in my collection but it return 404 Not Found error. Here's how the things is organized In the interface for ...
chas's user avatar
  • 11
0 votes
0 answers
33 views

Better way to store mongo collections details as Java constants

public class MongoDBConstants { // Define the collection names public static final String USER_COLLECTION = "users"; public static final String PRODUCT_COLLECTION = "...
Bharath Tej Chinimilli's user avatar
0 votes
0 answers
32 views

Keep same Object ID when Migrating from MongoDB to MongoDB Atlas

We are migrating our MongoDB database that is currently set up on an EC2 instance, to MongoDB Atlas. What we noticed is that after exporting the DB in JSON format and importing it to the new MongoDB ...
Alangoodie's user avatar
0 votes
1 answer
50 views

Getting delay in Mongo DB with updateOne

I am updating few fields in a document with java and updates get complete with in 4ms. I am going to db to fetch same documentjust after the update completes. I am not getting updated documents. Any ...
Bat's user avatar
  • 135
1 vote
1 answer
43 views

How to fetch related user info when fetching all posts in MongoDB

Hello I am new to MongoDB. I want to fetch all posts with user details of who created the post. I have two collections. users collection: [{ "_id": { "$oid": "...
user's user avatar
  • 63
1 vote
0 answers
18 views

How convert MongoDB query to MongoDB Kotlin Driver

I'm trying to use the MongoDB Kotlin Driver to perform some queries on a MongoDB database, but I'm having trouble converting the queries from the MongoDB shell syntax to the Kotlin. For example, I ...
Raydel Leyva Blanco's user avatar
0 votes
0 answers
46 views

How to fix Error In MongoDB Nodejs: RangeError: The value of "offset" is out of range. It must be >= 0 && <= 17825792. Received 17825794

I've encountered this bug when adding data to the MongoDB database. When my variable 'i' reaches , the issue occurs. (i = 0 -> 60000) export const addQuestion = async () => { const data = ...
Mai Đức Thắng's user avatar
0 votes
0 answers
29 views

MongoDB grouping on Subdocument Query Performance on Large Dataset

I have a large collection in mongodb. It has around a million documents in that collection. But when i run aggregation pipeline on it, it takes almost 60 seconds to return unique values. I cant get ...
NKS's user avatar
  • 77
1 vote
1 answer
43 views

How to find who has birthday based on two string filds "day" and "month" in mongodb

I have this datamodel in mongoDB: { "_id" : "KPu78LNXYKfraRF94", ... "aboutPage" : { ... "birthDay" : NumberInt(27), "...
podeig's user avatar
  • 2,631
0 votes
0 answers
63 views

How to create a filter that matches a nested value against a value of the parent collection in mongodb?

Consider the following collection: { "_id" : (guid), "basePrice" : 5000, "productCategories" : [{ "_id" : (Guid), "categoryName"...
Neo's user avatar
  • 143
0 votes
2 answers
59 views

MongoServerError: Invalid $set :: caused by :: Expression $in takes exactly 2 arguments. 1 were passed in

{ "offers" : [ { "name" : "min", "prices" : [ 8, 15, 18 ] }, { "...
Md Nazmul Islam's user avatar
0 votes
0 answers
27 views

After some aggregation stages, I want the unwind result with other collections fields with their values as blank/empty

I am usign mongo version as v5.0.19 I have 2 collections with the data in it as below: Collection 1 - external_S_P_FLAT_main_api: [ { "_id": { "$oid": "...
Hemant Joshi's user avatar
0 votes
1 answer
33 views

MongoDB query to transform documents

I have the documents structured in MongoDB 6.0 as below: [ { "_id" : ObjectId("6555a7d7c2d9de74abb09de8"), "tagName" : "tag1", "...
Bhanu's user avatar
  • 945
0 votes
0 answers
21 views

Issue with Projection in MongoDB C# Driver Using $facet Stage

Background: I'm working with the MongoDB C# driver and facing a projection issue when using the $facet stage in an aggregation pipeline. The projection works as expected in a simple scenario but fails ...
J.Paravicini's user avatar
1 vote
1 answer
74 views

Connection between JasperStudio and MongoDB

I tried connecting mongodb to Japerstudio using the MongoDb connection option and the JDBC Option by following some tutorials. The MongoDB option is not even able to connect to the Database using the ...
Vivek Buri's user avatar
-2 votes
0 answers
50 views

how to get the current index in a $map?

https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/ Is it possible to extract the index of the current element in $map?
Bear Bile Farming is Torture's user avatar
0 votes
1 answer
66 views

Getting undesired result while using $set in mongodb with string containing period

I have an object stored in my collection in mongodb { "students" : { "[email protected]" : {"gender" : "M", "marks" : 30}, "[email protected]&...
Vishal's user avatar
  • 3
0 votes
2 answers
85 views

MongoDB Aggregation on nested levels

I use MongoDB 4.4. I'm trying to make a Mongo aggregation query that would return me a document with nested arrays. To specify the context: I have offers, which contain modules, which contain items, ...
skumy's user avatar
  • 21
0 votes
1 answer
51 views

How can I attach a header to the column without it

I have this dataset _id: 654e312d4ff391e4ef2244ad Id: 2 SepalLengthCm: 4.9 :3 PetalLengthCm: 1.4 PetalWidthCm: 0.2 Species: "Iris-setosa" and mongodb recognize like this, { "Id":...
HunterNicky's user avatar
0 votes
0 answers
52 views

Mongos connection not cleared

We have MongoDB shard server setup with Router + Config + 2 Shard servers [MongoDB version 4.4] and accessing the mongos connections via 4 servers with PHP7. Recently add 1 extra server(4+1=5) with ...
tkraja mdu's user avatar
0 votes
0 answers
11 views

Trying to create a Mongo view to flatten the data

I've been trying to create a Mongo View, but looking for help. I have records structured like this in Mongo and am trying to flatten the structure using a view for a reporting solution: { "...
Phil M's user avatar
  • 1
1 vote
2 answers
73 views

How can I change blank header in mongodb?

I have this collection: { A:1 B:2 :3 D:4 } We need to replace a whitespace with C for example, how can I achieve this? Like this { A:1 B:2 C:3 D:4 } I tried renaming, ...
HunterNicky's user avatar
0 votes
1 answer
31 views

After some aggregation stages, I want to filter the array within the document that matches with the conditions

I have 2 collections 1. external_S_P_FLAT_main_api 2. external_S_C_FLAT_main_api The collection has data as below. "external_S_P_FLAT_main_api": [ { "_id": { "$oid&...
Hemant Joshi's user avatar
0 votes
0 answers
18 views

How to apply $lookup on array elements without $unwind

I have an faqs array inside my provider schema, containing a title and content as a reference to a translations collection. How do i get an object containing all matching docs in place of title and ...
gaurav kelkar's user avatar
0 votes
2 answers
47 views

Sorting based on a field and add a specific record on top of the results

I have the below set of user records, I need the results in such a way that the logged-in user (ObjectId("653222c20489664953bbaf1a") and status: Active) should come first, followed by the ...
Neha's user avatar
  • 61
1 vote
0 answers
15 views

Find all collections in mongodb with specific field-irrespective of nesting level

I want Mongo DB script which list the all the collection having the specific field irrespective of the nesting level meaning if I am searching for field empId it can be directly available in one ...
reddy's user avatar
  • 89
0 votes
0 answers
25 views

Update many documents in MongoDb from a JSON file using a common custom index

New to Mongo and have been reading up on the Mongo documentation for UpdateMany, but I can't seem to find an answer to my specific scenario. Let's say I have a collection, MyCollection. I create a new ...
SCVandal's user avatar
1 vote
1 answer
52 views

MongoDB query for given nested document

Here i have shown only single document but array has such multiple documents, I want to get all the documents which have Internal storage ( Memory -> Internal ) of 128GB Data : [ { &...
Uday's user avatar
  • 35
1 vote
1 answer
51 views

Reactive mongo group elements and count them

I have a MongoDB database where are storage different files, those files can be png, jpg, pdf, here an example: { "_id" : "id of the document", "metadata" : { ...
ahabrahante's user avatar
0 votes
0 answers
37 views

I have used $function in my mongoose aggregation query. Can we use moment inside that $function?

I have written mongoose aggregation query where I am using $function inside that with $add field.In that function I am converting out some dates, for that I have used moment library. But it throws me ...
Parth_Choksi's user avatar
2 votes
1 answer
51 views

Select nested fields in filtered aggregation

How can I aggregate, filter nested array and project selected nested fields? I have the following data: { "teacher": "Ben", "students": [ { "name":...
Marc Grue's user avatar
  • 5,799
0 votes
0 answers
35 views

when start the mongos for sharding Getting error

Quickly I gave the details, I have 4 Linux VMs with MongoDB installation. 1. Mongodb is for config so in Mongod.conf file enabled replication with shading like below replication: replSetName: "...
Aravind rajamani's user avatar
0 votes
1 answer
24 views

How to get intersection data of a field from multiple Mongodb document's field's data. Want a Mongo aggregate Query which I can add in my query

I am already using a Mongo db Aggregate Query to get a array of output. email will be the array of emails as input in the query. **aggregateQuery** = [ { '$match': { 'email': { ...
Vishal Gupta's user avatar
0 votes
1 answer
31 views

MongoDB aggregate query result in bactches?

Suppose I have a Collection Posts with schema { _id, userId, name, createdAt, location, teamId } I want to group the data by userId { $match: { teamId: new ObjectId(teamId), ...
Abhishek Bansal's user avatar
0 votes
0 answers
27 views

How to configure mongo trigger for dev and prod cluster using Nodejs?

How to configure mongo trigger for dev and prod cluster using Nodejs ? I have some query regarding mongodb trigger. I have 2 cluster - ( DEV and PROD ) I want to create 2 trigger 1 for dev and 1 for ...
Atique Ahmed's user avatar
0 votes
1 answer
55 views

Is there a specific file extension type to save MongoDB queries equivalent to sql file extensions

Apologies if the title does not make sense, not too sure what's the best word to put it in just few words and hopefully this is also a good place to ask such question. Anyways, I am currently using ...
Dora's user avatar
  • 6,826
0 votes
0 answers
15 views

MongoDB bulk insertion in a collection not updates DB

I have a query regarding MongoDB insertion of a new field . In a collection , there is an array of objects and I want to introduce a new field in the array. Usually, the array size in a record starts ...
RagaSGNur's user avatar
  • 199
0 votes
0 answers
17 views

MongoDB Enterprise Advanced - Secondary/Backup Node Licensing

A bit stuck on MongoDB licensing for their Enterprise Advanced version. Does anyone know if secondary/backup DBs require an additional subscription? We've setup our DBs in the three-node format as ...
costoperator's user avatar

1
2 3 4 5
348