Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would MVC-like code work in Node.js?

Tags:

I'm starting to get my head around node.js, and I'm trying to figure out how I would do normal MVC stuff. For example, here's a Django view that pulls two sets of records from the database, and sends them to be rendered in a template.

def view(request):     things1 = ThingsOne.objects.all()     things2 = ThingsTwo.objects.all()     render_to_response('template.html, {'things1': things1, 'things2': things2}) 

What might a similar node.js function look like?

like image 900
Brian Tol Avatar asked Feb 01 '10 19:02

Brian Tol


People also ask

Can we use NodeJS in MVC?

In this tutorial, we'll learn about the popular architectural pattern Model-View-Controller (MVC) followed by building and structuring an application in Node. js using MVC.

What is MVC node Express?

MVC stands for Model, View, Controller is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each one of these components is built to handle specific development aspects of an application.

Does express JS follow MVC?

ExpressJs does not follow any specific pattern. You are free to structure your project as you wish.

Does MVC use JavaScript?

The MVC architecture in the angular framework is pretty straightforward. The architecture relies upon HTML and JavaScript. Controllers which are written in JavaScript collect user input/events from the View, process them, and sends them to the Model. From the Model, the information is sent to the View.


1 Answers

http://boldr.net/mvc-stack-node-js-ejsgi-scylla-mustache is a great little article with a full github example of a MVC pattern using dirfferent Node modules. It also lists alternate modules currently available. It answered this question for me better than http://howtonode.org/ which has some good tuts but I couldn't find anything on MVC there.

like image 74
Denis Hoctor Avatar answered Sep 23 '22 19:09

Denis Hoctor