To decide between storing and retrieving data from a JavaScript object or a backend database

As a newcomer to the programming world, I am currently immersing myself in the development of my initial web application using Node and Express, with connectivity to a MongoDB backend.

In a specific section of my app, users input values into a form that includes selecting one of 30 unique Door types from a list. When the form is submitted, the chosen Door type is queried in the pre-loaded database to retrieve its Weight value. Subsequently, this Weight value is utilized in conjunction with two other user-submitted values (height and width) for a calculation process, facilitated by callback functions upon form submission.

The primary inquiry here pertains to whether streamlining the process might involve storing weights of different door types in a JavaScript object, thus enabling retrieval of the appropriate weight through dot notation. With doors predominantly characterized by name, weight, and one other attribute, this approach could eliminate the necessity of querying the database altogether. Any insights or recommendations on optimizing this workflow?

Answer №1

Mongodb is commonly utilized for managing databases that are rich in documents but have few relationships. Your specific application will benefit from using Mongodb due to its scalability. Additionally, you can easily perform basic mathematical operations when storing and retrieving documents by utilizing the built-in functions mentioned here.

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

I expect my webpage to automatically redirect after I submit a user login form

I'm in the process of creating a website with two main pages: a Homepage and an admin panel page. Utilizing the MERN stack for development. At this moment, I have set up a scenario where clicking on the admin link in the navigation bar triggers a us ...

Using Node.JS and MySQL to optimize data retrieval by combining queries to define variables and select data efficiently

My SQL query that functions perfectly in PHPMyAdmin seems to be causing issues in Node.JS: SET @row_number=0; SELECT * FROM blah blah @row_number blah blah; When attempting to execute both queries in Node.JS using con.query("SET @row_number=0; SELECT * ...

How can I get an object returned from a Mongoose find method in NodeJS?

I am currently working on developing a node.js API with Mongoose, However, for a specific task, I need to retrieve the object as a variable from my find operation. This is what I have so far: exports.get_info = function(_id) { Session.findById(_id, f ...

Text alignment issues cause animation to vanish

Utilizing particles.js, I set up a full-screen particle effect by specifying the animation to be full-screen with height: 100vh;. This worked perfectly as intended. However, when attempting to add text on top of the particle animation and center it vertica ...

How can I send a variety of different MongoDB queries to EJS?

After a user submits a form on my website, I aim to present them with a breakfast item, lunch item, and dinner item. Initially, I envisioned achieving this by individually performing db.collection("recipes").findOne queries, then passing the result to an E ...

What is the best way to implement the addMore event in my custom slot components when working with Vue Formulate?

I need help customizing the 'add more' button for group repeatable fields in Vue Formulate. I have created a custom slot component that is functioning correctly, but I am struggling to determine the click event needed to add another field when th ...

Tips on how to direct the attention to a text box within a unique dialog, ensuring that the blinking cursor highlights the input area

Is there a way to set autofocus on a textbox when opening a custom dialog box? I've tried using the autofocus attribute for the input field, but it doesn't seem to work for me. Can anyone provide guidance on how to achieve autofocus for a textfie ...

Sliding the container with a width adjustment and left margin fails to display all images

In the provided HTML code below, there is a functionality to move images horizontally by clicking on buttons: $(document).ready(function() { calculate_width(); $('#moveleft').click(function() { var loga = $('#marki #loga'); ...

Saving a revised JSON file using AngularJS

Currently, I am in the process of developing a phonegap application using AngularJS that relies on a .json file to store an array of entries. The main goal I am aiming for is to enable users to mark specific entries as favorites and then utilize that data ...

Is the alert failing to appear during the onbeforeunload event across all web browsers?

Check out the following code snippet that is functional. window.onbeforeunload = function() { someAjaxCall(); } This code block, however, does not perform as expected: window.onbeforeunload = function() { someAjaxCall(); alert("Success !!"); ...

Utilizing regular expressions in Javascript to retrieve multiple instances

This paragraph contains a specific string txt = "Local residents o1__have called g__in o22__with reports..."; that requires extracting numbers between each occurrence of o and __ If we use the following regex: txt.match(/o([0-9]+)__/g); We will obtain ...

What is the best method to determine when 20% of a "<section>" element is within the user's view?

Looking at the layout, I have two sections that take up the entire page. My goal is to detect when the second section is 20% visible while scrolling, and then smoothly scroll to lock that section in place so it occupies the full space. This action should a ...

Modifying table background color using AJAX and jQuery?

Scenario: My web page is designed to automatically search for a specific cell input by the user. If the cell has been input with a value, the table's background color will turn red; otherwise, it will remain green. Currently, the table has not been p ...

Implementing dynamic AngularJS functionality within an older HTML structure using JQuery

I am facing an issue while trying to load dynamic content using AngularJS. In my system, I have legacy pages that utilize JQuery for dynamic loading. However, as I am developing new features with AngularJS, I am encountering the same problem with dynamic ...

Using Google Search API to populate a MySQL Database with data

Seeking assistance and understanding for my query. I am looking to extract data from the Google Search API, save it into my database, and then display it. Despite using ajax.html, I encountered an error. The specific data I aim to store includes snippets, ...

Switch between various height and width options using JavaScript

Is there a way to create a toggle that changes both the height and width of an element when it is clicked? <div class="flexbox-container" id="main" onclick="staybig()">Create Account</div> .flexbox-container { ...

Having trouble choosing multiple options from autocomplete drop-down with Selenium web-driver in Python

I am currently in the process of automating a webpage built with Angular that features an auto-complete dropdown with numerous elements. My goal is to click on each individual element and verify if it populates all the fields below accordingly. Below is th ...

Node.js API MongoDB request restricted to local host environment

I'm currently developing an application and I am retrieving data from an API running on a Node.js platform that queries a MongoDB. The app functions properly when accessed locally, but encounters issues when accessed from an external source. It' ...

Activate Popover with Hover and simply click anywhere to dismiss

Currently utilizing Bootstrap 4 and intrigued by the popover feature that activates on hover and closes when clicked anywhere. I'm also interested in making links functional within the popover. Any suggestions or tips on how to achieve this? $(doc ...

Ways to retrieve dropdown values

My HTML code is as follows: <select class="height_selected"> <option>Select Height</option> <option ng-model="userHeight" ng-init="1" value="1">123 cm</option> <option ng-model="userHeight" ng-init="2" v ...