Can't Create mongoose model

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

const mongoose = require('mongoose');
const mongodb = require('mongodb');
const mySecret = process.env['MONGO_URI'];

mongoose.connect( mySecret , { useNewUrlParser: true, useUnifiedTopology: true });
const  Schema = mongoose.Schema;
const personSchema= new Schema ({
  name:{type : String, required : true},
  age: {type : Number},
  favouriteFood : [{type : String}]

let Person;
Person = mongoose.model('Person',personSchema);
const createAndSavePerson = (done) => {

  done(null /*, data*/);

const createManyPeople = (arrayOfPeople, done) => {
  var janeFonda = new Person({name: "Jane Fonda", age: 84, favoriteFoods: ["eggs", "fish", "fresh fruit"]});, data) {
    if (err) return console.error(err);
    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;

I can’t create a model on my mongoose. Please what is wrong with my code

Your browser information:

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

Challenge: Create a Model

Link to the challenge:

Hello there,

I would have assumed the logs would have a useful error?

Here is your schema:

Here is your code:

Hope this helps

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

so how can i see the log

<p>So how can i use the log</p>

The answer is you have a typo.

As for the logs, this depends on where you are developing:

  • If you are using Replit: The logs are in the console
  • If you are using Glitch: The logs are called the “Logs”
  • If you are developing locally: The logs are in the terminal

Hope this clarifies

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