create entity, load data and read array objects in node js

dinesh
Posts: 8
Joined: Sat Dec 01, 2018 1:01 am

create entity, load data and read array objects in node js

Post by dinesh » Sat Dec 15, 2018 1:26 am

I am creating an employee entity.

Code: Select all

/* Employee business entity */
function createEmployee(
    nameParam, ageParam, employerParam, salaryParam
)
{
    this.Name = nameParam,
    this.Age = ageParam,
    this.Employer = employerParam,
    this.Salary = salaryParam
}
Now I am going to assign some value on my entity and store that in employeesList array:

Code: Select all

var employeesList = [
    new createEmployee("David Joe",40,"codexplore.com",30000),
    new createEmployee("Mark Straus",43,"codexplore.com",40000)
]
Now this how I am going to read the entity data from employeesList array.

Code: Select all

printEmployee(employeesList);

function printEmployee(arrayParam)
{
    /* Loop through Employee array */
    arrayParam.forEach(function(employee) {
    /* Show all elements from Employee 1 object */
    for (var key in employee)
    {
         console.log(key + " : "+ employee[key])
    }
}, this);
}

create entity in node js and load data
read array of objects in node js