为什么我在 Mongoose MongDB 中收到此错误?
我的代码:
// 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();
运行代码后出现错误。请指导我如何解决此错误。 我们将不胜感激您的帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论