Should I refrain from storing user files on my server?

Greetings! I am currently working on an Express js + React js application and using MySQL for database management.

I have successfully stored user information like email, hashed passwords, and user IDs in the database. However, now I want to create an inventory for each user.

This inventory would consist of an array containing the item ID and name that the user owns. How can I implement this? Would it be better to update my database structure or store this information in a text/json file on the server? Any advice is appreciated!

Answer №1

If you're looking to avoid calculating inventory every time a user requests it, consider computing it once and saving the result for that specific user to prevent unnecessary calculations in the future. There are various ways to cache computation results, such as utilizing tools like redis.

After a user's request is made, calculate for that specific request and save the result in cache.

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

Vue.js: The Power of Manipulating Strings

Why is the filter method not working with this.userId, but it is working with the hard-coded value "admin"? How can I resolve this issue? computed: { UidMessages: function() { return this.Messages.filter(function(m) { return m ...

Tips for duplicating specific div elements

Is there a way to create copies of selected divs within the same panel using a Javascript report designer? I attempted to achieve this by using the following code snippet: function DesignerClone() { $(".ui-selected").each(function () { va ...

The CSS styling is not being rendered correctly on the AngularJS HTML page

Encountering a puzzling situation here. Our angular controller is successfully delivering data to the page, but we are facing an issue with rendering a table due to an unknown number of columns: <table border="1" ng-repeat="table in xc.tables"> ...

Accessing Facebook through the React create app login

I recently developed a React Webapp using the create-react-app module. My current challenge involves integrating Facebook login, but I'm encountering some obstacles. I am unsure about where to incorporate the Facebook JavaScript SDK asynchronously to ...

In React, components will consistently render the initial code

I have a chat application that requires authentication and uses cookies. Here's what I've been attempting: class AppHeader extends React.Component { constructor(props) { super(props) } render() { if (cookies.get(' ...

Using CSS or JavaScript to trigger events while scrolling with touch

Imagine a scenario where multiple boxes are stacked on top of each other: <div style="width: 100%; height: 100px; background-color: red"> stuff </div> By clicking or touching them, the background color can be easily changed using CSS (:hover, ...

Leverage a collection of paths when performing actions within the app.all() method in Node.js Express

In my express application, I have a list of routes that need specific actions to be performed on them. For example: app.get('/xyz', file.xyz); app.post('/xyz1', file.xyz1); app.post('/xyz2', file.xyz2); app.post('/xy ...

Ways to display console.log output in VS Code?

Sorry if this question is a bit unclear, but I'm struggling to figure out how to display the results from my console.log (line 14) in the console/terminal. I want to see the random RGB values generated for each column every time I click the button, bu ...

Error Encountered During JavaScript Form Validation

Currently, I am troubleshooting a website that was created by another developer. There is a form with JavaScript validation to ensure data is accurately entered into the database. However, I am puzzled as to why I keep receiving these alert messages. Pleas ...

Adjusting the height of a container dynamically in React while flex items wrap using CSS

In my React project, I have a container called "answers-container" with multiple buttons inside it, laid out using flexbox with flex-wrap: wrap to allow them to wrap onto the next line when the container width is exceeded. However, I'm facing an issu ...

Encountering ECONNRESET: An issue arises while querying the database consecutively in Node.js

My Node.js file contains methods to read and write data from my PostgreSQL database on Heroku. I am utilizing the 'pg' module to interact with the database. The issue arises when I call my getSleepMode function consecutively, resulting in an ECON ...

Utilizing Arrays in Mongodb and EJS

Is there a simple way to work with arrays in MongoDB and EJS? For example, on the front end, users can click buttons to add values to an array: $("#buttonOne").click(function() { food.push("Kiwi"); $("#foodObject").val(food) }); $("#buttonTwo").click(fu ...

Update the nested radio button to a new value

I have a series of radio button lists generated using ng-repeat. I've managed to capture the selected item successfully. Now, I am attempting to set the default value for the radio buttons. Could someone please provide assistance? Below is my code sni ...

How can one adhere to Angular's recommendation of "always using dots with ngModel" while working within isolate scopes?

Currently, I am working on developing an Angular application utilizing Bootstrap. To reduce the impact of Bootstrap on my HTML code, I have implemented two directives specifically for forms: form-control.js module.directive('formControl', func ...

What are the steps to incorporate a jquery-ui checkbox into a widget?

I have encountered an issue where using a jquery-ui checkbox within a container that has the class ui-widget-content is causing a problem with the CSS rules. Specifically, the ".ui-widget-content .ui-state-hover" rule is overriding the .ui-icon-check rule, ...

Can you explain the concept of Cross-origin requests?

My JavaScript application is designed to detect single, double right, and double left clicks. A single click triggers an asynchronous request to the HTTP server, while the rest are intended to change the user interface on the client side. However, I am str ...

Trouble with incrementing JavaScript dictionary values within a nested for loop

I am currently working on analyzing shark attack data with d3.js using a csv file named shark.csv. I have encountered a problem while implementing a nested for-loop in my code. The csv file contains information about shark attacks categorized by continent ...

I am facing an issue where both curl and file_get_contents are not functioning properly after

When attempting to access a user's city information using coordinates, I have encountered an issue with the response not being displayed in my console. The process involves a javascript function that takes latitude and longitude data, sends it to a PH ...

Guide to utilizing the post method in Node.js

In my Node.js file, I have implemented a function that calculates the sum of two numbers. This functionality is accessed by sending data via Postman using the POST method. var express = require('express'); var bodyParser = require('body-pars ...

Using Mysqli Real Escape String in Queries: To Escape Inside or Outside?

I'm confused about using real escape string for security against SQL injection. Is there any difference if I include the real escape string within the query itself, like this: $ano = $_POST['ano']; $SQL->query("DELETE from viewers WH ...