Hi, after successfully submitting the first two challenges, node v12.16.1 throws this error:
{
ok: 0,
code: 8000,
codeName: 'AtlasError'
}
When submitting the solution, FCC tells me:
// running tests
Creating and saving a db item should succeed (Test timed out)
// tests completed
Creating and saving a db item should succeed
My code so far:
the .env file:
MONGO_URI="mongodb+srv://cluster0.diflp.mongodb.net/<password>"
myApp.js:
-1-
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true, useUnifiedTopology: true
});
-2-
const Schema = mongoose.Schema;
const personSchema = new Schema({
name: {
type: String,
required: true
},
age: {
type: Number
},
favoriteFoods : [
{
type: String
}
]
});
const Person = mongoose.model('Person', personSchema);
-3-
var createAndSavePerson = function(done) {
var janeFonda = new Person({name: "Jane Fonda", age: 84, favoriteFoods: ["vodka", "air"]});
janeFonda.save(function(err, data) {
if (err) return console.error(err);
done(null, data)
});
};
In package.json:
"mongodb": "^3.6.2",
"mongoose": "^5.9.20"
Browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
.
Challenge: Create and Save a Record of a Model
Link to the challenge: