Ticket: Create/Update Comments Data Issue

I am getting an error in “Can post a comment”:

FAIL  test/create-update-comments.test.js
  Create/Update Comments
    ✕ Can post a comment (171ms)
    ○ skipped Can update a comment
    ○ skipped Can only update comment if user posted comment

  ● Create/Update Comments › Can post a comment

    expect(received).toEqual(expected) // deep equality

    - Expected  - 1
    + Received  + 1

    - "60c66fb6515dae9212dab649"
    + "5a9427658b0beebeb6975200"

This is my code for CommentsDAO.addComment:

  static async addComment(movieId, user, comment, date) {
    try {
      // TODO Ticket: Create/Update Comments
      // Construct the comment document to be inserted into MongoDB.
      const commentDoc = {
        name: user.name,
        email: user.email,
        movie_id: movieId,
        text: comment,
        date,
      }
      return comments.insertOne(commentDoc)
    } catch (e) {
      console.error(`Unable to post comment: ${e}`)
      return { error: e }
    }
  }

I am unsure on what I am doing wrong, it seems like a data issue.

sample_mflix.movies: 23530
sample_mflix.comments: 50304

I just reloaded the sample dataset.

Any help would be appreciated!

There is and assertion in the api validateConnection.js:

    let resultsAssertion = assert(23539, response.total_results)

I am missing 9 documents, did I missed a step somewhere?

Hi @Eduardo_Cancino, welcome to the community.
Were you able to figure out the issue behind this? Your query looks fine to me and usually, we recommend a sample-data refresh on the Atlas, but since you have already performed that, I am not sure what the issue might be.
Please let us know if you are still looking for a resolution on this, and in case you have figured out what went wrong, please post that as well, as it might help other learners if they also face something similar.

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

Hi @SourabhBagrecha,

I did found the issue in another thread.

Thank you!

1 Like