MongoDB and Mongoose - Create and Save a Record of a Model

's happening:
Please help me on this model i seems the code is not upto date maybe some can help with model save no longer accepts callback

###Your project link(s)

solution: http://localhost:3000

require(‘dotenv’).config();
const mongoose = require(‘mongoose’);
const { Schema } = mongoose;
mongoose.connect(process.env.MONGO_URI);

const personSchema = new Schema({
name: { type: String, required: true },
age: Number,
favoriteFoods: [String]
});

const Person = mongoose.model(“Person”, personSchema);
exports.PersonModel = Person;

const createAndSavePerson = (done) => {
const person = new Person({name: “david”, age: 21, favoriteFoods: [“pizza”, “moo”]});
person.save(function(err, data) {
done(null, data);
});
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

MongoDB and Mongoose - Create and Save a Record of a Model

Leaving a link to localhost isn’t much help, that’s on your machine. The problem is this code cant run on its own without the other files.

Don’t update the dependencies or use the promise based approach (async/await or .then).

https://mongoosejs.com/docs/api/model.html#Model.prototype.save()


https://mongoosejs.com/docs/7.x/docs/migrating_to_7.html#dropped-callback-support

There was something wrong with the DNS since i was doing it on my local server so i used glitch and it passed thanks for the info