Back-end development using Node JS Bugs

Describe your issue

In the Back-end development path using Node JS there are 4 bugs that prevent me from completing the path 100%.

Specifically:

  • In 3 Database Integration, the MongoDB Connection Event Logger exercise is marked as approved, but it’s not counted toward the progress, remaining yellow. And in the Blog Posts and Comments Modeling exercise, it’s not possible to approve it, even with the solution code provided.

  • In 4 Building Complete APIs, the exercises Mapping REST Principles to a To-Do List API and Personal Bookshelf API both pass but do not count toward path progress and remain yellow.

Screenshot

Hey @waldohidalgo, can you provide me the solution you are trying to submit, because I checked and the solution is working fine. And I have updated the test cases which you are failing the other questions also so you can check what mistakes are you doing.

Hello, all the passed tests were considered. The only remaining exercise is the “Blog Posts and Comments Modeling” exercise, which fails the “Is there a reference between posts and comments schema” test. This is my solution code:

I have passed the mongodb uri in this format (replacing the username, password and cluster address with the respective data from my mongo database):
const uri=“mongodb+srv://username:password@cluster-address/test?retryWrites=true&w=majority”

const postSchema = new mongoose.Schema({
  title: String,
  content: String,
  author: String,
  comments: [
    {
      type: mongoose.Schema.Types.ObjectId,
      ref: "Comment",
    },
  ],
});

// Comment Schema
const commentSchema = new mongoose.Schema({
  text: String,
  author: String,
  post: {
    type: mongoose.Schema.Types.ObjectId,
    ref: "Post",
  },
});

// Models
const Post = mongoose.model("Post", postSchema);
const Comment = mongoose.model("Comment", commentSchema);

Afterwards I tried to use the solution code provided on the platform and it doesn’t work either:

// Comment Schema
const commentSchema = new mongoose.Schema({
  text: {
    type: String,
    required: true,
  },
  author: {
    type: String,
    required: true,
  },
  post: {
    type: mongoose.Schema.Types.ObjectId,
    ref: "Post",
    required: true,
  },
  createdAt: {
    type: Date,
    default: Date.now,
  },
});

// Post Schema
const postSchema = new mongoose.Schema({
  title: {
    type: String,
    required: true,
    trim: true,
  },
  content: {
    type: String,
    required: true,
  },
  author: {
    type: String,
    required: true,
  },
  comments: [
    {
      type: mongoose.Schema.Types.ObjectId,
      ref: "Comment",
    },
  ],
  createdAt: {
    type: Date,
    default: Date.now,
  },
});

// Models
const Comment = mongoose.model("Comment", commentSchema);
const Post = mongoose.model("Post", postSchema);

Something is happening because the relationship is displayed correctly in the console:

@waldohidalgo so when I am writing your solution as well as my solution from the question both are submitted and accepted, can you try to reset the IDE from the button given on the left tool bar or try changing the mongo URI. But if the error is still there feel free to reach out on abhay@codechef.com.