简体   繁体   English

通过猫鼬连接到MongoDB

[英]Connection to MongoDB via mongoose

I am using Gulp building system. 我正在使用Gulp构建系统。 When I try to connect to my local MongoDB using mongoose I got error mongoose.connect is not a function . 当我尝试使用mongoose连接到本地MongoDB出现错误mongoose.connect is not a function

Connection code: 连接代码:

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');

Your code seems fine. 您的代码似乎很好。 Are you sure you correctly installed mongoose? 您确定正确安装了猫鼬吗?

npm install --save mongoose

Your problem isn't that you're using mongoose directly in react ? 您的问题不是您在反应中直接使用猫鼬吗?

Mongoose is a node module: "elegant mongodb object modeling for node.js". Mongoose是一个节点模块:“用于node.js的优雅mongodb对象建模”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM