I was wondering if someone could show me how to get a string value from mongodb and store that in a variable.
db.model("users").findOne({username: username, password: password}, {type:1},
function(err, data) {
if(err) {
return "Error";
} else if() {
return "No records";
} else {
return data.type;
}
}
);
I get the type value when I run this.
But how do I store this in a variable outside this function?