Why does the “distinct” and “count” commands happen so slowly on indexed items in MongoDB?

I am using MongoDB (Atlas) to hold my ~55 million time-series documents in a database The documents typically look like this: { “_id” : ObjectId(“5c8f1fb127fcc613f422677d”), “capture_time” : ISODate(“2019-03-18T04:33:51Z”), “key” : “9727eec91/51c922a.png”, “e_id” : 20702 } Not all documents have an ‘e_id’, so I have indexed “e_id” like so: { “v” : 2, “key” : {…

Connecting Spring Boot and MongoDB in Docker

I am trying to connect MongoDb and Spring Boot in docker-compose.yml. This is it – version: “3.7” services: app-server: container_name: spring build: . ports: – “8080:8080” restart: always depends_on: – db db: container_name: mongo image: mongo ports: – “27017:27017” restart: always volumes: – ./datadir:/var/lib/mongo My Dockerfile for Spring FROM openjdk:8-jdk-alpine VOLUME /tmp ARG JAR_FILE COPY…

MongoDB collection return empty object, why?

I’m trying to fetch all the data from my collection called “users” and all i’m getting back is undefined. In my folder and file named leaderboard/lb.js, and yes, my database is called collections: const mongoose = require(“mongoose”); let out = {}; mongoose.connect(`mongodb+srv://ramoth123:${process.env.MONGOPASS}@ramfish-bot-mgpji.mongodb.net/collections?retryWrites=true&w=majority`, { useNewUrlParser: true }, function(err, db) { if (err) throw err; //let dbo…

How to return Objects with empty sub Array document if sub Array documents don’t satisfy the match condition in MongoDB?

I’m facing one difficulty in projecting MongoDB values. Problem: Mongoose is not returning Objects if sub Array documents don’t satisfy the match condition in mongoose. MongoDB Query: db.fruits.aggregate( { $match: { “isActive”: true, fruitId: “kipld” } }, { $unwind: ‘$types’ }, { $match: { “types.isActive”: true } }, { $group: { _id: ‘$_id’, name: {$first:…

Posting Audits with mix of embedded object and array using vue.js and mongodb

I have tried different methods. Below is my vue.js submit(e){ e.preventDefault(); // this.loading = true; let newDevice = { title: this._device, devices: [ { device: this.devices.device, rating: this.devices.rating, quantity: this.devices.quantity, operation: this.devices.operation } ], and my schema.. title: String, devices: [ { device: String, rating: String, quantity: String, operation: String } ], date: { type:…