I just started learning MongoDB and mongoose. I currently have the following structure:
database -> skeletonDatabase collection -> adminLogin
When I run db.adminLogin.find() from the command line, I get:
{ "_id" : ObjectId("52lhafkjasfadsfea"), "username" : "xxxx", "password" : "xxxx" }
My connection (this works just adding it FYI)
module.exports = function(mongoose) { mongoose.connect('mongodb://localhost/skeletonDatabase'); var db = mongoose.connection; db.on('error', console.error.bind(console, 'connection error:')); db.once('open', function callback () { console.log('Conntected To Mongo Database'); }); }
My -js -
module.exports = function(mongoose) { var Schema = mongoose.Schema; // login schema var adminLogin = new Schema({ username: String, password: String }); var adminLoginModel = mongoose.model('adminLogin', adminLogin); var adminLogin = mongoose.model("adminLogin"); adminLogin.find({}, function(err, data){ console.log(">>>> " + data ); }); }
My console.log() returning as >>>>
So what am I doing wrong here? Why am I not getting any data in my console log? Thanks in advance for any help.
Kris hollenbeck
source share