MongoDB Connections Spiking When Connecting from Node+Express

I am trying to create some APIs for my mobile app. I’m using Node+Express+Mongo+Firebase. Based on suggestions give in various other places (How to properly reuse connection to Mongodb across NodeJs application and modules) I’ve created below code structure: This is what I have in my mongoUtils.js: const MongoClient = require(‘mongodb’).MongoClient const uri = “mongodb+srv://user:password@blabla.azure.mongodb.net/bla?retryWrites=true&w=majority”;…

Why json.RawMessage enlarge mongoDb document size?

The following codes try to insert new documents into mongoDB through go.mongodb.org/mongo-driver data := “this is test string blablablablablablabla” type Doc struct { Version int “json:version, bson:version” Data string “json:data, bson:data” } dd := Doc{Version: 21, Data: data} dObj, _ := json.Marshal(dd) queryFilter := bson.M{“version”: 1} update1 := bson.M{“$set”: bson.M{“version”: 1, “data”: json.RawMessage(dObj)}} // insert…

How to do conditional nested lookup search in mongodb

I have 2 collections in mongodb 4.2: article – [Id,ArticletypeId,BestResponseId,Topic,PredecessorId] { Id: 1, ArticleTypeId:1, BestResponseId:2, Topic:”XYZ” }, { Id: 2, ArticleTypeId:2, PredecessorId:1 }, { Id: 3, ArticleTypeId:2, PredecessorId:1 }, { Id: 4, ArticleTypeId:2, BestResponseId:5, Topic:”ABC” }, { Id: 5, ArticleTypeId:1, PredecessorId:4 }, { Id: 6, ArticleTypeId:2, PredecessorId:4 } result-[Id,ArticleId,ResultTypeId] { Id: 1, ArticleId:1, ResultTypeId:2 },…

How to do conditional nested lookup search in mongodb

I have 2 collections in mongodb 4.2: article – [Id,ArticletypeId,BestResponseId,Topic,PredecessorId] { Id: 1, ArticleTypeId:1, BestResponseId:2, Topic:”XYZ” }, { Id: 2, ArticleTypeId:2, PredecessorId:1 }, { Id: 3, ArticleTypeId:2, PredecessorId:1 }, { Id: 4, ArticleTypeId:2, BestResponseId:5, Topic:”ABC” }, { Id: 5, ArticleTypeId:1, PredecessorId:4 }, { Id: 6, ArticleTypeId:2, PredecessorId:4 } result-[Id,ArticleId,ResultTypeId] { Id: 1, ArticleId:1, ResultTypeId:2 },…

How to use mongodb query to compare the element in DB to another element in an array stored in same collection

Here is my question. This is my sample records { “_id” : ObjectId(“5d9b69fae4757402b4b4ca0d”), “status_changed_utc” : [ { “status” : NumberInt(1), “time” : ISODate(“2019-05-20T23:03:10.000+0000”) }, { “status” : NumberInt(2), “time” : ISODate(“2019-05-23T23:04:03.000+0000”) }, { “status” : NumberInt(4), “time” : ISODate(“2019-05-23T23:05:06.000+0000”) }, { “status” : NumberInt(5), “time” : ISODate(“2019-05-23T23:05:07.000+0000”) }, { “status” : NumberInt(6), “time” : ISODate(“2019-05-23T23:05:09.000+0000”)…