Category "mongodb-query"

How to create nested array inside $group in MongoDB?

After some of the aggregation pipeline stages, my MongoDB Document has the following format: { "key": "A", "status": "To Do", "val": 4 }, {

Remove specific object from array during aggregation

I have documents with the following structure: {field: ["id1", "id3"]}, {field: ["id2", "id1"]} To query the documents I use aggregate({$match: {'field' : { $i

MongoDB : How to update a new field value according to existing field value in each document?

I am working on a project and it currently goes through each document to edit the field and lags a lot. { "Name" : "Susie" , "This Semester" : 10 , "Last Semest

MongoDB query inside an array

I want to use this mongoDB collection: [ { "_id": { "$oid": "627c4eb87e7c2b8ba510ac4c" }, "Contact": [ { "name": "ABC",

Delete object from inner schema in mongoose?

How do I delete object from inner schema in mongoose? I try to delete comments from the Holiday Schema, this is the holiday schema: const holidaySchema = new mo

How to use $arrayElemAt with MongoDb

I have the following pipeline, which I want to use it in Golang and convert it to bson.M. One way is using bson.UnmarshalExtJSON but I want to know what is exac

MongoDB indexes are ignored inside the $facet pipeline

I have all combination of compound indexes for this collection. The aggregattion query i used is: db.products.aggregate( [ { $facet: { "categ

'No write concern mode named 'majority`' found in replica set configuration' error

I'm trying to insert an object into mongodb via a POST request. The object that I send gets inserted in the db successfully, however I get the error mentioned a

how can I give order wise Projection in mongodb query

I am new to monngodb, my query is below $mng = new MongoDB\Driver\Manager("mongodb://localhost:27017"); $filter = [ "archival"=>0];

MongoDB: Find an object by its ID without knowing the collection

I have an mongodb databse with 100+ collections. I'm trying to find an object, with a known ObjectID, that belongs to some (unknown) collection of this database

MongoDB optimize indexes for aggregation

I have an aggregate on a collection with about 1.6M of registers. That consult is a simple example of other more complex, but illustrate the poor optimization o

Mongo Transporter PipeLine Data MisMatch Issue

I am using transporter pipeline to get sync my NoSQL DataBases between Source DataBase Mongo (Version=3.4) to Sinc Database Mongo (Version = 4.4). Here I establ

MongoDB - How to find for both string and string array

I'm a beginner at MongoDB. I want to find documents in MongoDB by favorite.foods. Here are documents { "_id":1, "favorite": { "color":"red", "foods"

RoboMongo can't use array filters?

Following on from "How to update collection and increment hours for ISO date". It seem that RoboMongo can't execute a query with an array filter: This same

Find balance from debit and credit entries mongodb

I have a Mongo collection like this: { "user_id" : "1", "branch_id" : "1", "trans_type":"DEBIT", "total" : 500 }, { "user_id" : "1", "b

How do I use Spring Mongo to group two fields and get a array of one fields based on the other?

Let me give a example here: Two entries in the collection Author: { "name" : "Joe" "Book" : "A" }, { "name" : "Joe" "Book" : "B" } Now, if I use the aggrega

MongoDB Duplicate Documents even after adding unique key

I have created a collection and added a unique key like this db.user_services.createIndex({"uid":1 , "sid": 1},{unique:true,dropDups: true}) The collection

How to convert a pymongo.cursor.Cursor into a dict?

I am using pymongo to query for all items in a region (actually it is to query for all venues in a region on a map). I used db.command(SON()) before to search i

How to Convert mongodb ISODate to string in mongoDB?

I have my ISODate in mongo as ISODate and I want to just that in string format with a specific datetime format. Here is the ISODate: ISODate("2020-04-24T1

How to search in array of array of object in mongodb

Suppose the mongodb document(table) 'users' is { "_id": "6065923bc5d509071857f6e6", "version": [ { "name": "1.1.0",