Please help inspite of writting everything correctly :(MongoDB and Mongoose - Create and Save a Record of a Model

Tell us what’s happening:
I am not able to pass the challenge in-spite of doing everything correctly

Your code so far

var createAndSavePerson = function(done) {
  const person = new Person({
    name: 'Keshav', 
    age: 18, 
  favoriteFoods: ['water']
  });, data) => {
    if(err) {
    done(null, data);
//I also placed URI in .env and 
//My dependencies are 
	"dependencies": {
		"express": "^4.12.4",
		"body-parser": "^1.15.2",
    "mongodb": "*", "mongoose": "*"

Your browser information:

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

Create a document instance using the Person constructor you built before. Pass to the constructor an object having the fields name , age , and favoriteFoods . Their types must conform to the ones in the Person Schema. Then call the method on the returned document instance. Pass to it a callback using the Node convention. This is a common pattern, all the following CRUD methods take a callback function like this as the last argument.

/* Example */

// ..., data) {
  // your stuff here...

Link to the challenge:

What do the failing tests say? What else have you tried? Have you been able to narrow down the problem at all?

The failing test says
// running tests Creating and saving a db item should succeed // tests completed

× Creating and saving a db item should succeed

I tried a lot but nothing happened So, I decided to look for hints and solution then after exactly writing the same solution my test case was not passed .

Help me where I am lagging

If you are using Glitch, then in the bottom left corner of your screen there is a button called Tools. Click it and select logs to open the console. Clear the console then get your App URL and submit it to FCC. Then observe what is being written in the console. It should give you more descriptive error.

Yes I am using Glitch

This is error shown in the log
Missing done() argument
[object Object]
Missing done() argument
[object Object]

What does this means ? I am unable to understand please help

I get something similar but still unable to understand this :
“If you scroll down into the myApp.js file, you have another declaration of Person and another declaration of createAndSavePerson. JavaScript will use the last declaration of each instead of the first (the ones you modified). Comment out the other ones and you will pass the tests.”

Please help I am eagerly waiting

Please post a link to your Glitch project. Ensure it is a link to the editor’s view without the .env, and not the link you put in the solution box.

With this, it will be a lot easier to help you.

Link without .env and in eidtor’s view is :

I tried to open the live version of your project but it keep on loading. Not sure that is same for you. I remixed your project, then added my URI to the .env file and it was working for me! I was able to pass the FCC test.
So I suggest you look into the URI and make sure it is correct. Also try giving the URI directly without using the .env file. I have a feeling that there is an issue with your .env file

I copied this URI and also put the special character less password then pasted in .env as

see the photo how do I know whether it is connected and how to connect it with glitch
In photo at the top only two things are green ticked but connect option is not

Help me to understand

Thank you, for link the project. Here are somethings I suggest you try (try one, then move to the next, if it does not work):

  1. Delete the collection of your Person in your database. Go to the beginning of the challenges, and resubmit your link, in the order the challenges should be completed.
  2. Add this to the appropriate section in your package.json:
"dependencies": {
    "express": "^4.17.1",
    "body-parser": "^1.19.0",
    "mongoose": "^5.9.5",
    "mongodb": "^3.5.5"
  1. Change your to this:, data) {
    if (err) return console.error("3 ",err);
    done(null, data)
  • Do not call done with err.

I hope this helps. Let us know what the outcome of each is.

From the following three options First worked for me and thank you very very much for all the helps given by Sky020, acskck and ArieLeslie.:tada::tada::gift::gift::tada::tada:

As acskck said error was coming because Mongodb was not collecting info in the database and then I created new cluster from scratch , I think as the AWS server to which I connect was far from asia that was the reason but somehow it was done… :sweat_smile:

And sorry for getting crazy for this , as it made my schedule one week late but now I am ready to cover up … Thanks!

1 Like