Skip to main content

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'String, unique: true},
  password: {type: 'String'String},
  key: {type: 'String'String},
  keySecret: {type: 'String'String}
}, {collection: 'user'});


var User = mongoose.model('user',userSchema);

module.exports = User;

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;

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;
added 86 characters in body
Source Link
Echo
  • 305
  • 1
  • 4
  • 14

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;

Im having trouble using the .find() function within mongoose on a node js server

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;

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;
Source Link
Echo
  • 305
  • 1
  • 4
  • 14

Node js / Mongoose .find()

Im having trouble using the .find() function within mongoose on a node js server

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;