sydney69 sydney69 - 1 month ago 9
Node.js Question

How to get data data in the database

When I run this,

Module.find(function(err,Module){
console.log(Module);
});


It returns data like

{ _id: 57f769b130bbaf129c586eb5, Name: 'Sydney', Status: true },
{ _id: 57f76e19f30d3c1ca02d002b, Name: 'zamora', Status: true },


How to get the data of
Name
and
Status
? and store it in a variable
like in java.

String name = db.getString("Name");

Answer

you can use for loop:

var Name=[];
var Status=[]; 

for(i=0;i<Module.length;i++) {
     console.log(Module[i].Name);
     console.log(Module[i].Status);
     Name[i] = Module[i].Name;
     Status[i]= Module[i].Status;
}

in this way, you can get data of Name and Status and store it.