MongoDB and Mongoose - Create a Model

const Schema = mongoose.Schema;
const personSchema = new Schema({
name: {type: “String”, required: true},
age: “number”,
favoriteFoods: [“string”]

});

const Person = mongoose.model(“Person”, personSchema);
const createAndSavePerson = (done) => {
const person = new Person({
name: “Sona”,
age: 12,
favoriteFoods: [“Chicken Noodles”, “Fruits”]
});
person.save(function(err, data) {
return console.log(err)
done(null, data);
});
// when i run my console shows me “SyntaxError: Unexpected end of input” now i don’t know what to do anymore please someone can help please

When posting code on the forum, please insert it inside backticks to make it easier to read. You can click on the </> icon (or CTRL+e) and paste the code where indicated.

Also, could you share a link to the challenge you’re working on and also to your full code please?

here are the link https://replit.com/@bowak/boilerplate-mongomongoose#myApp.js)

thank you

https://www.freecodecamp.org/learn/back-end-development-and-apis/mongodb-and-mongoose/create-a-model

You haven’t closed this off with a curly bracket. That’s your only issue here.

I got a change now but it still doesn't work 

I just submitted your repl link and it passes for me.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.