nestjs-boilerplate
nestjs-boilerplate copied to clipboard
Best practice for adding user_extra extension entity and related CLI commands
Background: I would like to extend the user entity by adding an extra property class, such as user_extra. What would be the best practice to achieve this in this project? For example, should I create a separate entity and link it with a relation, or is there a preferred approach in your codebase?
Additional question: Are there any CLI commands or scripts already set up in this repository to help generate new entities? If so, could you please share some guidance or examples?
Thank you!
@zieglar
I would like to extend the user entity by adding an extra property class, such as user_extra. What would be the best practice to achieve this in this project? For example, should I create a separate entity and link it with a relation, or is there a preferred approach in your codebase?
It's up to you and based on your project's requirements. You can add properties directly to the User entity, or you can create an additional entity via the CLI and attach it to the User entity.
Additional question: Are there any CLI commands or scripts already set up in this repository to help generate new entities? If so, could you please share some guidance or examples?
You can find the video here https://github.com/brocoders/nestjs-boilerplate?tab=readme-ov-file#description-
@Shchepotin I mean, if I need to add a subsidiary entity class to the user's infrastructure, how to operate it is the best practice, or do you suggest adding a new entity module?
@zieglar excuse me for my unclear answer, but not sure that there is a best practice for this. In your case, you can create a new module "UserExtra" and add a relation to User.
@Shchepotin It is not recommended to put User-related models under users/infrastructure/persistence/relational, right?
@zieglar, usually we put a new module in the /src even if it is related to another module.
Alright, thank you for the reply.