[ad_1]
I am attempting to learn how to use mongoose and using WebDev simplified’s video ‘Mongoose Crash Course’ and trying to return the model user. However, when I attempt to run the code, the user model does not return and throws a,
“MongooseError: Operation users.insertOne()
buffering timed out after 10000ms.”
I have followed his steps to the tee and am still getting this error. I have also made sure to install each dependency in addition to checking other forums for help but still cannot understand. I cannot get past 8:36 of the tutorial. Provided below is the video link.
//script.js
const mongoose = require('mongoose')
mongoose.connect("mongodb://localhost/testdb")
const User = require("./User")
run()
async function run() {
const user = await User.create({ name: "Kyle", age: 26 })
//const user = new User({ name: "kyle", age: 26 })
//await user.save()
console.log(user)
}
//user.js
const mongoose = require("mongoose")
const userSchema = new mongoose.Schema({
name: String,
age: Number
})
module.exports = mongoose.model("User", userSchema)
[ad_2]