I'm getting this when trying to connect my Node app to Mongodb:MongoError: Authentication failed. I can access my databases in the Mongo shell with this command:mongo -u admin -p admin123 --authenticationDatabase admin I'm on a Ubuntu server and everything seems to be running. I'm thinking my mongoose.connect syntax is off and according to some research I did it may have to do with versions of Mongo and Mongoose not playing nicely with each other. Does any of this syntax look off to you?var express = require('express'); var mongoose = require('mongoose'); var Schema = mongoose.Schema; var app = express(); mongoose.connect('mongodb://admin:admin123@127.0.0.1:27017/food'); var usersSchema = new Schema({ id: String, vote: Number }); var bkyes = mongoose.model('bkyes', usersSchema); app.get('/bkyes', function(req, res) { bkyes.find({}, function(err, bkyes) { res.send(bkyes); }); }); app.listen(3000); Let me know if you have any advice for troubleshooting this. Thank you all!!
Submitted December 02, 2016 at 06:17AM by joWebDev
No comments:
Post a Comment