Category "mongodb-query"

MongoDB - Loop through array of arrays

I have a document that contains an array of arrays in my MongoDB collection. { "platformId":"CMC_123", "carInfo":[ ["Toyota",20,"White"],

Document Read and insert with locking/transaction in nodejs with mongodb

In reservation system, only 5 different user can create bookings. If 100 user call booking api at same time than how to handle concurrency with locking. I am us

MongoDB Shell deleteMany() function is not working

I have to delete all the data called owner.login. It means in json data, there are one more Object called owner. So I tried in MongoSH Beta(MongoDB Compasss) an

Trying to call function by using db.eval("functionName()") in mongoDB compass version 4.4 But getting error as TypeError: db.eval is not a function

db.system.js.insertOne({ _id: 'getMachinewiseLogDat', value: function () { return db.Smx_22235_ShiftOEEDaily.aggregate([ { $group: {

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