Open tanerochris opened 4 years ago
Hey @tanerochris, I noticed you are using
// in /api/user/login.js
...
const User = mongoose.model('User');
...
// use User to do operations
Within the api routes without strictly importing all the models on the path to the said route. this isn't too good as you may request a model which is not already registered, so explicitly requesting a model from the file will be better.
All models are imported/loaded/registered before the app actually runs, that's done in app.js, using glob module which gets all model the file paths by pattern. Importing a module by filepath, in case an adjustment is done to a file path then will mean changing all reference of this path in the different files it was used unlike loading it and just calling it as I did.
On Sat, Jun 6, 2020 at 10:07 PM Rodrick Nfinyoh M notifications@github.com wrote:
Hey @tanerochris https://github.com/tanerochris, I noticed you are using
// in /api/user/login.js ...const User = mongoose.model('User'); ... // use User to do operations
Within the api routes without strictly importing all the models on the path to the said route. this isn't too good as you may request a model which is not already registered, so explicitly requesting a model from the file will be better.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BuildForSDG/voxnostra/pull/24#issuecomment-640158005, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACC3JXMOVHA2Z2MZWKEVLD3RVMN7TANCNFSM4NSCJXOQ .
-- My twitter @tanerochris What I've built https://tchizer.com Developer Circle Buea Lead facebook.com/groups/DevCBuea/ Whatsapp +237 678431904
Description
Merged all existing PRs
20 #16 #22
How Has This Been Tested?
No test is written for the front end , just backend API endpoints.
Screenshots (if applicable, else remove this line / section)
Checklist: