How does a Node.js MVC work? [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this questionI'm really interested in systems written in node.js. Specifically using it to create an MVC application.
I was thinking about the differences between designing a node.js MVC and doing the same in PHP. Since PHP is loaded and interpreted at runtime, a change to one of my controllers or views will be reflected in live server performance as soon as the file on the server chan开发者_StackOverflow社区ges.
I'm wonderring though, since node.js is compiled, is an application restart required every time you push changes?
If not, does MVC effect server performance overall, since the server has to read the files at request-time versus having the whole application sitting in memory? Or do perhaps have it all wrong and I'm missing the point entirely? (if so please educate me 'cause I'm dying to know!).
Thanks! - A
Check out Express for a take on Node framework development. You can see some MVC there. The HTTP url parsing available in Node really makes writing a router easy for tossing requests to 'controllers' and requiring in models is easy.
Node can use a variety of databases from SQL (Postgres, etc) to No-SQL (CouchDB, Mongo, etc)
Here is an example of an already available "restart-node-on-changes" add-on
Here is a list of plugins/modules for Node
A typical node.js MVC application would store the model data in memory and on some kind of saved database like mongoose.
Every time a model changes it goes through your js and saves to the database. It shouldn't need restarting at all.
If you change your code you do indeed have to restart the server. I presume there are various programs out there to stop this from happening.
Although it's not Recommended
These are also Relevant: EventedIO
精彩评论