MongoDB and Mongoose - Create a Model

Tell us what’s happening:

This test isn’t passing, either I’m missing something obvious or there is an issue with my setup,

Here is my code;

require('dotenv').config();
let mongoose = require('mongoose');
let dbUri = `mongodb+srv://giancoppola:${process.env.MONGO_PW}@cluster0.gjnjhuw.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0`
mongoose.connect(dbUri, { useNewUrlParser: true, useUnifiedTopology: true });

const Schema = mongoose.Schema
let personSchema = new Schema({
    name: { type: String, required: true },
    age: Number,
    favouriteFoods: [String]
})
let Person = mongoose.model('Person', personSchema);
const p = new Person({name: "name", age: 28, favouriteFoods: ["1", "2"]})
console.log(p);

Here is the result;

The payload of the request looks like this;
name: Mike
age: 28
favoriteFoods: pizza
favoriteFoods: cheese

It looks like maybe the test isn’t passing because the payload doesn’t match the response, but that also shouldn’t be part of this challenge?

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

Challenge Information:

MongoDB and Mongoose - Create a Model

For anyone who comes to this post looking for answers, I spelt favoriteFoods as favouriteFoods, with a u, so the fields didn’t match, and I wasted 3 hours :slight_smile:

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