My code:
// MODULES
const mongoose = require("mongoose");
// CONNECTING TO THE DATABASE
const url = "mongodb://localhose:27017/fruitsDB";
mongoose.connect(url, {useUnifiedTopology: true, useNewUrlParser: true});
// CREATE
// schema
const fruitSchema = new mongoose.Schema({
name: String,
rating: Number,
review: String
});
// model
const Fruit = mongoose.model("Fruit", fruitSchema);
// collection
const fruit = new Fruit({
name: "Apple",
rating: 7,
review: "Pretty nice."
})
fruit.save();
I am getting error after running the code. Please guide me on how to solve this error. Your help will be appreciated.