My project link validation problem

Tell us what’s happening:
Hello everyone, please my project link shows invalid while the information is visible in the console and not in the database.

Your code so far

require('dotenv').config();
const mongoose = require('mongoose');
mongoose.connect('mongodb+srv://mon-project-wee:<password>@<datab>.brqps.mongodb.net/monprojectWee?retryWrites=true&w=majority');

let Schema = mongoose.Schema;
let personSchema = new Schema({
  name: {
    type: String,
    required: true
  },
  age: Number,
  favoriteFoods: [String]
});
let Person = mongoose.model('Person', personSchema);

var createAndSavePerson = function() {
  let person = new Person({name: 'EDOUKA EPOH WILFRID', age: 34, favoriteFoods: ['ananas', 'bananas', 'cakes']});
  person.save(function(err, data) {
    if(err){
      console.log(err)
    }else{
      console.log(data)
    }
  });  
};

const createManyPeople = (arrayOfPeople, done) => {
  done(null /*, data*/);
};

const findPeopleByName = (personName, done) => {
  done(null /*, data*/);
};

const findOneByFood = (food, done) => {
  done(null /*, data*/);
};

const findPersonById = (personId, done) => {
  done(null /*, data*/);
};

const findEditThenSave = (personId, done) => {
  const foodToAdd = "hamburger";

  done(null /*, data*/);
};

const findAndUpdate = (personName, done) => {
  const ageToSet = 20;

  done(null /*, data*/);
};

const removeById = (personId, done) => {
  done(null /*, data*/);
};

const removeManyPeople = (done) => {
  const nameToRemove = "Mary";

  done(null /*, data*/);
};

const queryChain = (done) => {
  const foodToSearch = "burrito";

  done(null /*, data*/);
};

/** **Well Done !!**
/* You completed these challenges, let's go celebrate !
 */

//----- **DO NOT EDIT BELOW THIS LINE** ----------------------------------

exports.PersonModel = Person;
exports.createAndSavePerson = createAndSavePerson;
exports.findPeopleByName = findPeopleByName;
exports.findOneByFood = findOneByFood;
exports.findPersonById = findPersonById;
exports.findEditThenSave = findEditThenSave;
exports.findAndUpdate = findAndUpdate;
exports.createManyPeople = createManyPeople;
exports.removeById = removeById;
exports.removeManyPeople = removeManyPeople;
exports.queryChain = queryChain;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36

Challenge: Create and Save a Record of a Model

Link to the challenge:

If you look at the syntax from the previous challenge you can refer to the “Node convention” part and how it is done there. Passing done to the handler function and then calling done with error if there is an error or calling it with null, data otherwise.

1 Like

Thank you very much, it is the solution you proposed that works.

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