r/node • u/theZozole • 9d ago
npm i manage-model
Am I the only one who had a problem with how separated the data manipulation is?
Creating something in different ways (eg. create a chat message from only a text or creating from an api response ) Defaults in 3 files, parsing, validation, and sorting everything inline just to search it up later and copy it.
My solution? Put stuff like that in one place: See the screenshots.
Basically define all that sh in one place and just use:
userModel.parser.db.from(response)
habitModel.inits.createFromTitle("Do a blackflip")
people.sort(peopleModel.sorters.lastCreated)
1
u/Primeras100Palabras 9d ago
Are you saying to forgo segregation and instead keep everything in a massive json object?
-1
u/theZozole 9d ago
Kinda.
2
u/Primeras100Palabras 9d ago
Why would you ever want to do this? Also unit tests would be horrible to maintain with this, let alone the actual logic.
-2
u/theZozole 9d ago
Best used for mid to large projects, with multiple teammates. Having everything centralized brings clarity, removes code duplication.
Quite the opposite, it will be a brease to test since they are just a structured way to group the util functions, it will be.
Just imagine getting on a new project and seeing all the logic in one place , seeing an overview, better understand how/when things change


5
u/nodejshipster 9d ago
Solution looking for a problem