Skip to main content
10 votes

Checks user level and limit the data before saving it to mongoDB

According to www.lizard.ws the original's function cyclomatic complexity is 29 and for the second version is 22. Both numbers are usually considered high, and teams aim for much lower values (...
Adrian Iftode's user avatar
9 votes
Accepted

Checks user level and limit the data before saving it to mongoDB

I am not a mongoDB user but is there not some type of validation API, not sure if it can be used on schemes. If it can then maybe that is the better option for your code. The Question It have been ...
Blindman67's user avatar
  • 22.9k
5 votes

Checks user level and limit the data before saving it to mongoDB

I would suggest to refactor the code to make it cleaner using a function that checks user level and limits ...
Margon's user avatar
  • 189
4 votes
Accepted

"Clean Architecture" design pattern with Node.JS and MongoDB

Your code looks very structured and nicely written, but to my understanding, your solution is not "clean architecture" (CA) as described by uncle bob. Your solution is an MVC solution. In clean ...
Adi Cohen's user avatar
4 votes
Accepted

A React - Typescript custom hook for any request (GET, POST, PUT, DELETE) to my back end

The biggest part is that the code works and it looks okay. I only have a few concerns about unnecessary rerenders and inconsistent UI because of inaccurate status state. Below are a few minor things I'...
Sean W's user avatar
  • 156
3 votes

Upload .JSON product list to MongoDB and upload image to AWS S3

There's nothing outstandingly wrong, there are some minor points that can be improved. The main concern that I have is the amount of logic happening inside the ...
Quill's user avatar
  • 12.1k
3 votes

Checks user level and limit the data before saving it to mongoDB

After looking at your code for a while, I think I understood your requirements. They can be summarized in this table: ...
Roland Illig's user avatar
  • 21.9k
2 votes
Accepted

Upload .JSON product list to MongoDB and upload image to AWS S3

In general I would say the code looks fine as far as functionality, though there are a few specific points which I will mention below with more detail. The broadest critique I have is that there are ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
2 votes

Checks user level and limit the data before saving it to mongoDB

Paradigm shift: Table-driven methods Once logic becomes complex enough, you may find it easier to manage the rules from a data structure than from code. Here's how I picture that working for you here. ...
benj2240's user avatar
  • 1,036
2 votes

Simple registration with NodeJS and Mongoose

Well, the code is fairly simple, but you've made it complex due to a bad design. I would encourage the following: Use Promises. Mongoose implements promises and so ...
Javier García's user avatar
2 votes
Accepted

Basic REST API for manipularing a MongoDB collection, using Node, Express, and Mongoose

This is not a full response to your question but what I could quickly jot down while looking at your post. Sorry, no insights to share. I would discourage you from choosing this answer in case someone ...
santanaG's user avatar
  • 413
2 votes
Accepted

Is this nodejs web-application spaghetti code?

From a medium review; The exception handling definitely raises eyebrows ex is not defined, so ...
konijn's user avatar
  • 34.4k
1 vote

Express error if agency not found middleware

I managed to accomplish this by adding the agency to res.locals. Here's the amended code: ...
mrmadhat's user avatar
  • 168
1 vote

Mongoose / MongoDB schemas for blog posts and authors

You can use the forEach function like this ...
Vedhagnanam's user avatar
1 vote

Upload .JSON product list to MongoDB and upload image to AWS S3

I agree with Quill - 90% of the stuff in your routes should be in other files. Routes must be concise, otherwise it's hard to tell which routes you have. Additionally, think about the processes, not ...
Johntron's user avatar
  • 1,110
1 vote

Mapping properties between two Objects of different structure

Maybe I don't understand the question exactly, but what's stopping you from just creating a function to do the mapping, like this: ...
Magnus Jeffs Tovslid's user avatar
1 vote

Saving a submitted Mongoose model, possibly with an uploaded image

Your modified code is better, but you can simplify this method even more. If you don't return anything from a function in a promise, it will be resolved with no value. There's no need to do ...
Gerrit0's user avatar
  • 3,501
1 vote
Accepted

MongoDB database connector on NodeJS

So I kind of figured this out. The db connector can be passed around like just another variable. Silly I didn't realise this before. I created a new file to abstract the model. dbOperations.js ...
Sashi's user avatar
  • 111
1 vote

Mongoose schema to store items from Wynncraft's API

As I see there is about 60 properties for each item in Wynncraft DB. I see two ways to improve your design: Distribute all properties across multiple schemas: basic item information (name, category, ...
Stexxe's user avatar
  • 525
1 vote

Creating Mongoose model

You have created a good model overall and I can only suggest you some consideration. Instead of using, created & ...
Muhammad Faizan's user avatar
1 vote
Accepted

Send Response To Browser without DB save confirmation

The big question to ask is: what happens when it doesn’t work? (For whatever reason) In your case, the user will probably think it worked, only to find out later that it didn’t and will most likely ...
rafasoares's user avatar
1 vote
Accepted

Session generator/checker utility for a server

For the most part this looks pretty good, there are only a few things which I would recommend changing. As Igor Soloydenko recommends, get rid of the comments which do nothing but restate the code. ...
Gerrit0's user avatar
  • 3,501
1 vote

Finding multiple documents

Why aren't using mongoose .populate() method instead? Refer to the Mongoose documentation for Population here
MartinsOnuoha's user avatar
1 vote
Accepted

Mongoose query using conditional formatting and regex

First, using new RegExp on user input is a bit like running eval on user input (though not nearly as bad - usually). If it can ...
Gerrit0's user avatar
  • 3,501

Only top scored, non community-wiki answers of a minimum length are eligible