****Connecting Mongoose to a database****

So far this is my code but I Still cannot connect to a database for Mongoose…
require(‘dotenv’).config();
MONGO_URI = “mongodb://Mongo23:@ac-xppqmnx-shard-00-00.mthfkb1.mongodb.net:27017,ac-xppqmnx-shard-00-01.mthfkb1.mongodb.net:27017,ac-xppqmnx-shard-00-02.mthfkb1.mongodb.net:27017/?ssl=true&replicaSet=atlas-10jovu-shard-0&authSource=admin&retryWrites=true&w=majority
const mySecret = process.env[‘MONGO_URI=’]
const mongoose = require(‘mongoose’);
let Person;

const createAndSavePerson = (done) => {
done(null /, data/);
};

const createManyPeople = (arrayOfPeople, done) => {
done(null /, data/);
};

const findPeopleByName = (personName, done) => {
done(null /, data/);
};

const findOneByFood = (food, done) => {
done(null /, data/);
};

const findPersonById = (personId, done) => {
done(null /, data/);
};

const findEditThenSave = (personId, done) => {
const foodToAdd = “hamburger”;

done(null /, data/);
};

const findAndUpdate = (personName, done) => {
const ageToSet = 20;

done(null /, data/);
};

const removeById = (personId, done) => {
done(null /, data/);
};

const removeManyPeople = (done) => {
const nameToRemove = “Mary”;

done(null /, data/);
};

const queryChain = (done) => {
const foodToSearch = “burrito”;

done(null /, data/);
};

/** Well Done !!
/* You completed these challenges, let’s go celebrate !
*/

//----- DO NOT EDIT BELOW THIS LINE ----------------------------------

exports.PersonModel = Person;
exports.createAndSavePerson = createAndSavePerson;
exports.findPeopleByName = findPeopleByName;
exports.findOneByFood = findOneByFood;
exports.findPersonById = findPersonById;
exports.findEditThenSave = findEditThenSave;
exports.findAndUpdate = findAndUpdate;
exports.createManyPeople = createManyPeople;
exports.removeById = removeById;
exports.removeManyPeople = removeManyPeople;
exports.queryChain = queryChain;

You need to connect the database with your connection string. Also, just for practice, I’d recommend you don’t share you connection string anywhere because then other people who see this can easily have access over your DB.

thanks for your help…

One more question how do I connect my string to the database? And what string do I connect it with?

Sorry for not seeing this, but your MongoDB connection string. It should look like this:

const url = "mongodb+srv://NOT_MY_USERNAME:NOT_MY_PASSWORD@NOT_MY_DB.abcde.mongodb.net/DB?retryWrites=true&w=majority";

const client = new MongoClient(url, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
});

You can see the instructions for setting up a MongoDB Atlas username and password here.

I hope that helps.