Hi all,
I seem to be getting the following error shown after the freecodecamp checks, as many others when trying to complete this challenge on repl.it as many others have:
// running tests
Creating and saving a db item should succeed (Test timed out)
// tests completed
Your project link(s)
I do not understand how the test is run as I can see the correct entry in the database but the fcc check doesn’t seem to recognize it.
I double checked that the database is accessible by all as ensured in the provided setup steps and also tried a few of the fixes others mentioned (i.e. removing the flags in the connect method, not having special characters in password, cleaning the collections, changing dbname etc.) but no luck with passing the tests.
*Also thinking this could be a server error if too many people are trying to run things on fcc but I don’t know.
Any help would be much appreciated.
my repl.it solution: boilerplate-mongomongoose - Replit
or as code:
require('do> tenv').config();
let mongoose = require('mongoose');
mongoose.connect(process.env['MONGO_URI'], {useNewUrlParser: true, useUnifiedTopology: true});
const personSchema = new mongoose.Schema({
name: {type: String, required: true},
age: Number,
favoriteFoods: [String]
});
let Person = mongoose.model('Person', personSchema);
const createAndSavePerson = (done) => {
const jamesBond = new Person({
name: 'James Bond',
age: 12,
favoriteFoods: ['kebap', 'corba', 'kisir', 'pizza', 'burger']});
jamesBond.save(function(data,err) {
if (err) return console.error(err);
done(null, data);
})
};
Your browser information:
User Agent is: Chrome/110.0.0.0
Challenge: MongoDB and Mongoose - Create and Save a Record of a Model
Link to the challenge: