Use model.find() to Search Your Database 2

Cuéntanos qué está pasando:
No me permite pasar esta prueba

Enlace(s) de tu proyecto

solution: boilerplate-mongomongoose - Replit

Información de tu navegador:

El agente de usuario es: Versión 102.0.5005.115 (Build oficial) (64 bits)

Desafío: Usa model.find() para buscar en tu base de datos

Enlaza al desafío:

Your code is passing for me with my own DB.

Are you getting any errors, did you check the network tab in the browser in submitting?

Also, you should be installing the exact versions of the libs as asked for in the first challenge.

1 Like

I get this error in the network tab:
“E11000 duplicate key error collection: test.people index: name_1 dup key: { name: “r@nd0mN4m3” }”

The replit.com virtual server automatically updates the packages, however, I don’t remember what the versions were when I started the first challenge.

You have the following in your package.json file. That is probably what the problem is. You need to change them to what is specified in the first challenge of this section.

        "mongodb": "^4.7.0",
        "mongoose": "^6.3.6"
1 Like

But I don’t remember the version of these packages
How can I know that?

In my previous post I mentioned they are in your package.json file. Check there and make the applicable changes there.

Did you change the Schema at some point?

I think I have seen that error from having used unique: true with the schema value. If you did you may have to delete the collection and try again.

try to change mongoose version ^6.3.6, from replit packages i couldn’t.
From the virtual server terminal I could, but it is not reflected in the replit packets, nor is it recorded in the packet.json nor with the --save option.
I still don’t know how to change it here in replit

Cheers,
Don’t use that option, see:
const personSchema = new Schema({
name: {
type:String,
required: true
},
age:Number,
favoriteFoods: [String]
});

Otherwise I would have tried
Thanks!

All you have to do is put the following in your package.json under dependencies. Make sure to only have one version of each package.

 "mongodb": "~3.6.0",
  "mongoose": "~5.4.0"

Then in the terminal type npm install. You may need to run npm uninstall mongodb and npm uninstall mongoose first to get rid of newer versions.

That is why I asked if you had changed the Schema. I know you are not using it now.

It’s just I know I have seen that error with the use of unique. Try deleting the collection and see what happens.

You can also search for “E11000 duplicate key error collection” to see why I’m suggesting this.


You should also install the correct versions of the libs as pointed out.