Im having trouble using the .find() function within mongoose on a node js server I've been trying to use this but I cannot get the key information out of my database.
user.find({key: 1} , function(err, data){
if(err){
console.log(err);
};
console.log("should be the key VVV");
console.log(data.key);
});
I'm mainly just having trouble wrapping my head around how this function takes queries and gives you back the response from your DB. If someone can break it down id be very thankful the mongoose docs weren't much help.
Also this is my user schema if it helps
var userSchema = new mongoose.Schema({
username: {type: String, unique: true},
password: {type: String},
key: {type: String},
keySecret: {type: String}
}, {collection: 'user'});
var User = mongoose.model('user',userSchema);
module.exports = User;