[SOLVED] Cannot pass MongoDB and Mongoose - Create a Model challenge

I have been stuck at this challenge for quite a few time since it is giving below error and not allowing me to complete it

Creating an instance from a mongoose schema should succeed

I have written below code so far and it is exactly the same code in hints page as well.

const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

const Schema = mongoose.Schema;

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

var Person = mongoose.model('Person',personSchema);

I can’t seem to find any issue with this. Do I need to wrap all of this code in a handle function and then use callback done()?

I am editing this on Glitch.

https://glitch.com/~mountainous-opalescent-meadowlark

Link to the challenge:

2 Likes

Anyone else having this isse?

2 Likes

It was just a stupid typo. I have used

favouriteFoods

but validator only consider

favoriteFoods

4 Likes

Thanks, this helped me

Thanks - solved my issue also. There’s a week of my life I won’t get back. OMG.

1 Like