Update .save() calls with UserRoleModel.create() #143
Update .save() calls with UserRoleModel.create() #143abhishek-nexgen-dev wants to merge 2 commits into
Conversation
Summary of ChangesHello @abhishek-nexgen-dev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request streamlines the user creation process by adopting the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors user creation logic to use the more concise Model.create() method instead of new Model().save(). The change is a good improvement for conciseness. I've pointed out a couple of minor issues: a misleading variable name and an inconsistency in the environment configuration example. Addressing these will improve code clarity and prevent potential configuration errors.
|
|
||
| # Database Configuration | ||
| DATABASE_URI=mongodb://localhost:27017/ # MongoDB connection URL | ||
| DATABASE_URI=mongodb://localhost:27017/user-service # MongoDB connection URL |
There was a problem hiding this comment.
There's an inconsistency between the database name in DATABASE_URI (user-service) and the DB_NAME variable on the next line (users-service). While the dbName option in the Mongoose connection options will likely override the one in the URI, it's best to keep these consistent to avoid confusion. I'd recommend making them match.
DATABASE_URI=mongodb://localhost:27017/users-service # MongoDB connection URL
There was a problem hiding this comment.
Hi @abhishek-nexgen-dev, since we have already DB_NAME in env. we don't need to update DB_URI
| const userRole = await UserModel.create(userData); | ||
| return userRole; |
There was a problem hiding this comment.
The variable name userRole is misleading here, as this function creates a User object, not a UserRole. A more appropriate name would be user or createdUser. Additionally, these two lines can be simplified into a single return statement.
| const userRole = await UserModel.create(userData); | |
| return userRole; | |
| return UserModel.create(userData); |
|
@abhishek-nexgen-dev, can you try global search to find all the occurance of .save() and then try to update it.
|
|
@sanjaysah101 okay |

Issue Number #137