Friday, 17 March 2017

NodeJS - What is the correct way/best practice to create model?

I'm new to NodeJS and I want to implement Model View Controller

In java I created a model like this:

public class Employee {

    private firstname:
    private lastname:
    .
    .
    ..........

    public Employee(String firstname, String lastname, ... ... ..){
       ...............
       ..............
    }

    // Getters and Setters
    .......
    .......
    .......

}

In Node this is what I did

  • Model enter image description here

  • Controller enter image description here

Another concern is the query should be inside the controller not in the model and the model should only contain an database fields, getters and setters.

Now may I ask you guys on what is the best practice or correct way in creating a model in nodejs.



via Gerald

No comments:

Post a Comment