[BETA] MongoDB and Mongoose - "Install and Set Up Mongoose"

[BETA] MongoDB and Mongoose - "Install and Set Up Mongoose"
0

#1

Hello,

I am getting an error and I don’t know what’s wrong.
I’m used to working with the MongoDB native driver, and I’m now learning mongoose through freeCodeCamp.

In the output, it says that I don’t have ‘mongooose’ as a dependency, which should be “mongoose”. Maybe that’s the problem? A bug?

I’ve taken a few screenshots:
1 - The FCC BETA website output;
2 - The package.json with all the dependencies;
3 - A strange console warning that I’ve never seen in my life;
4 - the myApp.js file.


#2

I am having a problem also on “Create and Save a Record of a Model”:

Schema and Model:

const personSchema = new Schema({
  name: { type: String, required: true },
  age: Number,
  birthDate: { type: Date, required: true },
  favoriteFoods: [String],
  creationTimestamp: { type: Date, required: true, default: Date.now }
})

let Person = mongoose.model('Person', personSchema)

When I save the document this way, freeCodeCamp test is successful, but the document is not saved in the database (mLab):

var createAndSavePerson = function(done) {
  let person = new Person({
    name: 'João Neves',
    age: 21,
    birthDate: '1995/07/11',
    favoriteFoods: ['Lasagna', 'Pasta']
  })
  
  person.save((err, data) => {
    if (err)
      return done(err)

    console.log(data)
    done(null, data)
  })
}

But when I do it this way, freeCodeCamp’s test fails but the document is saved in the database:

var createAndSavePerson = function(done) {
  let person = new Person({
    name: 'João Neves',
    age: 21,
    birthDate: '1995/07/11',
    favoriteFoods: ['Lasagna', 'Pasta']
  })
  
  person.save((err, data) => {
    if (err)
      throw err

    console.log(data)
  })
}

I’m also getting this warning on the console (?):
"(node:11040) DeprecationWarning: Mongoose: mpromise (mongoose’s default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html"