Optimal method for aggregating results from a search query across a collection of 100,000 documents

Assuming I have a collection with 100k documents structured like this:

{
    {
      userName: "cary"
      time: 50
      userId: 1
    }
    {
      userName: "john"
      time: 40
      userId: 1
    }
    {
      userName: "bliss"
      time: 50
      userId: 1
    }
    {
      userName: "ross"
      time: 40
      userId: 1
    }
    ...
    ...
    etc...
}

In order to query this collection and retrieve the count of users with times less than 40, 50, 60, etc., the expected result format would be:

{
  time: UsersCountWithParticularTime,
  ‘40’: 150,
  ‘50’: 50,
  ‘60’: 75,
  ‘40’: 90,
}

Is there a way to achieve this desired outcome?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In a React/Redux component, there is a requirement to automatically fill a specified number of fields based on the selection made

Although this question is reminiscent of a previous one I asked, I have since restructured my project to incorporate Redux. Currently, I have a component that dynamically generates dropdown contents based on a data response from the app. One of the dropd ...

Saving a base64 image in mongoDB is not supported

Utilizing Angular to send various types of data to my Node.js backend and store them in MongoDB has been working well for me. However, I've encountered an issue when trying to save a base64 image. For smaller images (around 30kB), everything works fin ...

javascript, issues with floating and displaying elements

I am currently working on creating a JavaScript menu that has a click function to smoothly slide up and down. Although the JavaScript code appears to be functioning correctly, it seems that there is some interference with the CSS. Despite attempting vario ...

AngularFire: Retrieve the $value

Having an issue logging the service.title to the console as it keeps returning as a strange object. .factory('service', function($firebase, FBURL, $routeParams) { var ref = new Firebase(FBURL + "services/" + $routeParams.serviceId); var titl ...

I'm having trouble figuring out the code for the path in the POST request for my basic login form application

I have built a basic login form application in node.js. Although I can successfully display the login form and input login data, my POST request to capture the login data is not functioning correctly. I am encountering a POST http://localhost:3000/client 4 ...

How to retrieve an object of type T from a collection of classes that extend a common base type in Typescript

In my current project, I have a class named Foo that is responsible for holding a list of items. These items all inherit from a base type called IBar. The list can potentially have any number of items. One challenge I am facing is creating a get method in ...

Which is better for MongoDB: storing a large nested document or dividing it into multiple collections?

I am a beginner with Mongo and I am currently exploring the most effective way to structure a section of my database. Picture a scenario where there is a document building tool that allows users to create a text document by selecting 'paragraphs' ...

Click to refresh a different component in ReactJS

My goal is to create a unique media player that can reload when a user wants to listen to an MP3 file. The concept is as follows: In media-player.js: - Display title, artist, and album art In programs.js: there is a button (LISTEN) that renders in medi ...

What are some effective strategies for structuring code with AngularJS?

I'm currently working on an app that utilizes ui router to append all HTML data to the following tag: <div class="app" ui-view > However, I want to add a header and footer to my app. My question is, should I include them in the index.html lik ...

Tips for creating a conditional confirm dialog box in Asp.net using JQuery/Javascript

I have some jQuery and traditional JavaScript mixed together to validate a textbox on my ASP sample page. There is a button, a textbox, and a button_click event in the code behind. When the button is clicked, I want to show an alert if the textbox is empty ...

Display the default child of vue-router 4

Need Assistance with Rendering Default Child View in Vue I am currently facing an issue with rendering the default child view for the Category view. I have come across a similar problem discussed on Stack Overflow, but it seems to be related to VUE2 and o ...

Is there a tool available that can convert a cron schedule into a more user-friendly, easy-to-read format?

My search for an NPM package that can handle this task has been fruitless so far. I am in need of a cron library that can convert a monthly cron job into easily readable text. For example, inputting 0 0 14 * * should output "Monthly", rather than the curre ...

Tips for incrementing or decrementing numbers to the right of the decimal in ReactJS

Currently working with react js and encountering an issue. I have an input field equipped with increment and decrement buttons situated on the right side. The problem arises when I try to increment the field, as it's actually the number on the right s ...

Introduce a pause interval between successive ajax get calls

I've created a script that uses an ajax GET request when the user reaches near the end of the page. $(function(){ window.addEventListener('scroll', fetchImages); window.addEventListener('scroll', fetchNotifications); }); ...

Why isn't my ng-click event working in Ionic/AngularJS?

I'm currently experimenting with Ionic/AngularJS, but I'm having trouble getting an alert window to appear. I began with a blank template in Ionic, and while the app launches in the browser window, nothing happens when the button is pressed. / ...

Managing asynchronous requests in a React-router wrapper

In order to verify if a user is authenticated in my React application, I followed the steps outlined in this guide. I developed a custom wrapper for the <Route /> component that checks whether the user is authenticated. If verified, the component is ...

PHP not able to retrieve JavaScript variable using Ajax

Resolved: I recently discovered that ajax only sends data in that particular moment, and redirecting creates a new instance. I spent hours searching through various Stack Overflow results for solutions, but none of them seem to work. My current challenge ...

Tips for sending data scraped from a website using Express

I have created a web crawler using Axios and am attempting to upload a file through Express. I currently have 10 different crawlers running with corresponding HTML form methods in Express. However, when I click the button, it downloads a blank file first ...

After a page reload, Material-UI stops functioning properly

I am currently working with Material UI in a Next.js project. When I run npm run dev, everything looks good. However, whenever I refresh the page, all the styling breaks. Has anyone experienced this issue before? It seems like Material-UI is no longer func ...

Steps to adding a collection of links (stylesheets, javascript files) to each html document

Is it feasible to add a list of links to multiple HTML files? I was inspired by W3 School's W3 Include functionality, which allows you to import blocks of HTML code into various files simultaneously, making it convenient for making changes across many ...