I’m working on learning node.js as a possible tool for web development. I understand how express.js works, but I’m not sure how to integrate mongoose models, I’ve tried searching google and here for an answer with no luck. Where should models go? Should they go in app.js, with the rest of the configuration and rorouting information? or should they go in a seperate file and imported like a normal module? Any information and resources would be appreciated. Thank you.
I’m working on learning node.js as a possible tool for web development. I understand
Share
I would recommend putting your models in separate files even if just for code organisation purposes. Create them as normal node modules and export the schema. Import the schema into your app.js and model them there: