0

I'm having trouble taking data from MongoDB and returning it to the console log, or even a javascript variable. I'd appreciate the help here:
This is my models/user.js directory

 var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/authentication');
var db = mongoose.connection;
var UserSchema = mongoose.Schema({
    username: {
        type: String,
        index:true
    },
    password: {
        type: String
    },
    email: {
        type: String
    },
    name: {
        type: String
    }
});
var User = module.exports = mongoose.model('User' , UserSchema);
module.exports.findingAll = function() {
   return User.find();
}

This is my routes/user.js file that calls on the model:

router.post('/', function(){

    var x = User.findingAll()
    console.log(x);
});

Finally, I have a form of type post that should trigger all of this and have everything return in the console.log

<form action="" method="post">
    <button name="foo" value="upvote">Upvote</button>
</form>
MrShedford
  • 137
  • 1
  • 2
  • 12

0 Answers0