Person model is not correct: mongoose

Person model is not correct: mongoose
0

#1

This is my code


and this is the challange

https://learn.freecodecamp.org/apis-and-microservices/mongodb-and-mongoose/create-a-model/


#2

Don’t use new mongoose.Schema

Use new Schema


#3

Hi,

The challenge is asking you to specify a default value, like this:

const schema = new Schema( {
  name: {
    type: String,
    required: true
  },
  age: Number,
  favoriteFoods: {
    type: [ String ],
    default: 'Pizza, of course'
  }
} );

#4

mongoose.Schema should be required unless you save mongoose.Schema into a new variable named Schema, like this: const Schema = mongoose.Schema. Otherwise Node won’t know what Schema is, right?


#5

Actually you are right,

I assumed he defined mongoose.Schema in to Schema already. Good catch, therefore @seinfeld70 you can ignore what I said above.


#6

I always make a copy to a new variable too. It looks cleaner to me :slight_smile: