no errors console logs []
const mongoose = require('mongoose');
const uri = "mongodb+srv://:@cluster0.yhy4bwu.mongodb.net/?retryWrites=true&w=majority";
const playerSchema = new mongoose.Schema({
fullname: String,
goals: Number,
assists: Number,
gamesPlayed: String,
shots: Number,
positionCode: String,
plusminus: String,
team: String,
timeOnIcePerGame: Number,
espnId: Number
})
mongoose.connect(uri)
.then(async ()=>{
model = mongoose.model('PlayersV3', playerSchema, 'PlayersV3')
const doc = await model.find({fullname : {$regex : new RegExp('a', "i")}}).limit(15).sort({goals: -1});
console.log(doc)
}).catch((error)=>{
console.log(error)
});
const local_uri = "mongodb://127.0.0.1:27017/nhl"
the localhost uri works
I have made sure that I have not misspelled my PlayersV3 collection
anything that would point me in the right direction helps
2
Answers
const uri = "mongodb+srv://:@cluster0.yhy4bwu.mongodb.net/Databasename?retryWrites=true&w=majority";
fixed it by adding in the database name as one of the query parameters
try using this one uri
assuming that your db name is "nhl" and also add you atlas username and password in uri.
syntax:
example: