Hey I am new to nodejs and mongoose and am trying to make a simple login and register form with my mongoHQ Database. I have register saving the data, and I am able to pull the data from the DB to print the object to the console, but how do I parse the object result for the username and password locations
// Define schema
var UserSchema = new Schema({
password: {type: String, required: true },
username: {type: String, required: true }
});
var User = mongoose.model('User', UserSchema);
User.password = req.body.password;
User.username = req.body.username;
console.log("going to find users");
User.findOne({username: User.username, password: User.password}, function(err, docs){
console.log(docs.username);
});
At this point I want to do something like docs.username or docs[0], can anyone give me some advice?